in reply to Re: 2d Array - making an array for the column then adding the values
in thread 2d Array - making an array for the column then adding the values
Good catch. What follows is a more detailed explanation.
The original code
$total += @$score;
adds an array to $total. What's the value of an array? Well, arrays don't naturally have a value. It turns out it's very convenient for arrays to return the number of elements it contains as its value. It allows us to replace calls to (non-existent) function array_length(@array) with just @array, a very common operation.
If you want to sum the values of the array's elements, you'll have to sum the values of the array's elements. I showed two ways of doing that in my earlier post.
|
|---|