If I define an array:
$pop = array(0,0,1,1,2,2,3,3,2,2,1,1,0,0);
and use array_sum($pop) I get a correct answer: (in this case, 18).
However if I use a MySQL table with defined ints (all sizes = 4) and the 1st column is the primary key (char(20)) and then use mysql_fetch_array:
$sql = "select * from table where p_key = \"$p_key\"";
$popfull = mysql_fetch_array(mysql_db_query("database", $sql));
then use array_slice to strip out the primary key data:
$pop = array_slice($popfull,1);
the array_sum function returns wrong answers.
The above is an example; my real problem has 100 ints (all size = 4). Array_sum on all elements returns twice the expected value (222 instead of 111), but this could be coincidence. Array_sum on an array_sliced subset returns values plucked from the air it seems.
A for-loop adding $pop[$index] works.
So where am I going wrong?