How can you calculate the sum of the elements of an array if some elements have values   ? I tried to remove or filter these values, but it did not work out. Array example:

 Array ( ... [11] => 2 [12] => 2 [13] => 1 [14] => 3 [15] =>   [16] =>   [17] => 1 [18] =>   [19] =>   [20] =>   ... ) 

1 answer 1

What's the problem? Everything counts:

 <?php $d = array( "1" => "bar", "2" => "foo", "3" => "3" , "4" => 2 , ); echo array_sum($d); //выводит 5