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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.