Jump to content

print_r() and array_sum()


derrick katungi

Recommended Posts

<?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...

Link to comment
https://forums.phpfreaks.com/topic/247424-print_r-and-array_sum/
Share on other sites

$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....

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.