From:             [EMAIL PROTECTED]
Operating system: openbsd/linux
PHP version:      4.0.6
PHP Bug Type:     Feature/Change Request
Bug description:  array_sum changed

I would like array_sum() to be able to handel multi-dimentional arrays.

this doesnt work.
  $test[][] = 1;
  $test[][] = 2;
  $test[][] = 3;
  echo array_sum($test);

ive wrote a simple function to make this work.
  function array_sum_multi($value, $reset = '1')
    static $sum;

    if ($reset)
      $sum = 0;
    if (is_array($value))
      foreach($value as $pos => $val)
        array_sum_multi($val, 0);
      $sum += $value;
    return $sum;

  $test[][] = 1;
  $test[][] = 2;
  $test[][] = 3;

  echo array_sum_multi($test);

just would be nice to see included.

  Chris Lee
Edit bug report at:

PHP Development Mailing List <>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to