Jump to content

[SOLVED] array_sum with $_POST array


chester

Recommended Posts

There are form fields named field[$i]. On process page I do:

<?
for ($i=0; $i<$entries; $i++) {
echo $_POST['field'][$i]."<br>";
}
$test = array($_POST['field']);
echo "Sum of the array is: ".array_sum($test)."<br>";
?>

The echo for-loop correctly prints each value. The array_sum, however, returns 0. Any help or suggestions are appreciated.

Link to comment
https://forums.phpfreaks.com/topic/142270-solved-array_sum-with-_post-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.