derrick katungi Posted September 19, 2011 Share Posted September 19, 2011 <?php error_reporting(0); $numm0 = array(1,2,3,4,5,6); $numm1 = array(1,3,4,5,6); $numm2 = array(1,2,3,4,6); $numm3 = array(1,2,3,5,6); for($i = 0;$i < 4;$i++) { print_r($numm.$i); } for($i = 0;$i < 4;$i++) { $w.$i = array_sum($numm.$i); print_r($w.$i); echo "<br>"; } ?> this code just hangs when executed. how can the syntax of the print_r() function and array_sum() function be modified? need help... Quote Link to comment https://forums.phpfreaks.com/topic/247424-print_r-and-array_sum/ Share on other sites More sharing options...
derrick katungi Posted September 19, 2011 Author Share Posted September 19, 2011 $data[numm0] = array(1,2,3,4,5,6); $data[numm1] = array(1,3,4,5,6); $data[numm2] = array(1,2,3,4,6); $data[numm3] = array(1,2,3,5,6); echo 'its here'. array_sum($data[numm0]).'<br>'; print_r($data); foreach($data as $key=>$value) { echo $key .'has a sum of ' .array_sum($value).'<br>'; } this is the way of doing it because print_r() and array_sum() have specific parameters. for example; print_r() has two parameters of which the second must be boolean.... Quote Link to comment https://forums.phpfreaks.com/topic/247424-print_r-and-array_sum/#findComment-1270644 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.