PHP Code:
<?php
$dollar = array(1,2,30);
$twoDollar = array(6,7,1);
$total = $dollar + $twoDollar;
echo array_sum($twoDollar) "\n" array_sum($dollar);
echo "total " $total;
?>
i am messing around with this becasue i would like to see how i can use this to benifit me say ina cart or something. any thoughts on why i am geting this error.
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';'
ANSWER
for some reason php sees them and cancels out any array of the same after the first. so if you have simular arrays i.e. like above then you would only ge the top array.
but if you want the sum of two arrays and they are the same use a command like this, and it should work just fine.
PHP Code:
<?php
$dollar = array(1,2,30);
$twoDollar = array(6,7,1);
echo array_sum( array_merge($dollar, $twoDollar) );
?>
well i hope this helps someone.
Bookmarks