|
Posted by Janwillem Borleffs on 12/27/05 12:36
Maximus wrote:
> I want to get the sum of the array key values.
>
> ex: $key1=>10, $key2=>15, $key3=>5
>
> I want variable $sum = 30.
>
Kimmo already supplied the solution; with associative arrays, use it with
http://www.php.net/array_values:
$array = array('key1'=10, 'key2'=15, 'key3'=5);
$sum = array_sum(array_values($array));
JW
Navigation:
[Reply to this message]
|