简体   繁体   English

将Excel数组公式转换为PHP或Javascript

[英]Convert Excel array formula into PHP or Javascript

I want to convert {=(PRODUCT(1 + A2:A85) )} into PHP or JavaScript. 我想将{=(PRODUCT(1 + A2:A85) )}转换为PHP或JavaScript。 I've searched google for "array excel formulas", but I could not find right result. 我已经在Google上搜索“数组Excel公式”,但找不到正确的结果。 How do I convert {=(PRODUCT(1 + A2:A85) )} ? 我如何转换{=(PRODUCT(1 + A2:A85) )} I have array for the A2:A85 range. 我有A2:A85范围的数组。 My array is like this: 我的数组是这样的:

var abc_array={2,3,4,5,67,7,8.........}. 

this is not tested but should work, im not the best at php so maybe someone could clean this up a little: 这未经测试,但应该可以工作,即时通讯不是最好的php,所以也许有人可以清理一下:

function product($array)
{
  $cons = $array[0];

    foreach($array as $num)
    {
        $cons = ($cons*$num);
    }

  return $cons;
}

Edit: just read @Eclecticist comment I missed the +1, but this shows as invalid if I try in Excel can you give some more info on what that does? 编辑:只是阅读@Eclecticist评论我错过了+1,但如果我在Excel中尝试,这显示为无效你可以提供更多信息吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM