chester Posted January 24, 2009 Share Posted January 24, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/142270-solved-array_sum-with-_post-array/ Share on other sites More sharing options...
.josh Posted January 24, 2009 Share Posted January 24, 2009 don't assign the $_POST['field'] as an array element of $test. Quote Link to comment https://forums.phpfreaks.com/topic/142270-solved-array_sum-with-_post-array/#findComment-745333 Share on other sites More sharing options...
chester Posted January 24, 2009 Author Share Posted January 24, 2009 d'oh. thank you for the quick response. Quote Link to comment https://forums.phpfreaks.com/topic/142270-solved-array_sum-with-_post-array/#findComment-745335 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.