Minase Posted May 30, 2008 Share Posted May 30, 2008 $d = 51; while ($d <= 60) { $costs2 =($d++ - 4 ); $costs1 = pow($costs2, 2.6); $coststr = (int) $costs1; $da = $coststr.",\n"; $dd = array($da); foreach ($dd as &$value) { $value = $value * 2; } echo $value."\n"; i have the above code,how can i make the sum of all arrays? cause its just returning the normal ones i want to have a variable that has the final answer in it here is what is curently return 44512 47016 49606 52280 55044 57894 60834 63862 66984 70196 i want a sum of those all numbers how can i do it? thank you. Link to comment https://forums.phpfreaks.com/topic/107981-solved-array-sum/ Share on other sites More sharing options...
MadTechie Posted May 30, 2008 Share Posted May 30, 2008 <?php $d = 51; $total = 0; while ($d <= 60) { $costs2 =($d++ - 4 ); $costs1 = pow($costs2, 2.6); $coststr = (int) $costs1; $da = $coststr.",\n"; $dd = array($da); foreach ($dd as &$value) { $value = $value * 2; } echo $value."\n"; $total = $total + $value; } echo "total = $total\n"; ?> Link to comment https://forums.phpfreaks.com/topic/107981-solved-array-sum/#findComment-553487 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.