Jump to content

[SOLVED] Looping Question for all the looping masters


dubstyleenation

Recommended Posts

I need to echo this statement

c=a1+a2+a3;

 

when I try, I only get a1a2a3.

$count = $_POST['count'];

for($i = 1; $i <= $count; $i++) { //$count in this case is 3. $count is never bigger than 6.
echo "a$i"; // Prints a1a2a3. I need it to print a1+a2+a3.
}

 

How can I put the loop results into an array and then implode the array with a plus (+) sign resulting in a1+a2+a3?

 

 

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.