Jump to content

$data $array - the print result mashes all the numbers together


deihler

Recommended Posts

Hello,   I am fairly new to PHP and I found some php code to print an array of numbers that create a combination - however, its slams all the numbers together without a space or a comma separator.   How can I separate the numbers in this array with the given code?  Ive attached a photo of the code.

 

 

 

 

array.jpg

Link to comment
Share on other sites

There are three echo() constructs that would produce output.  A fourth such construct is commented out so it won't run.
 

echo $data[$j];

echo ",";

echo "<br>";


If you'd like a space after the comma, add a space after the comma in the 2nd echo shown above.

If you're viewing this program's output in a browser, the "<br>" should produce a lineBReak.  If you're not, it will just be so much garbledy-gook.

Probably this line:

//echo "n"

Was actually mean to write a 'newline', like this:

echo "\n";


Enabling (uncommenting) that line (with the change as shown) would produce a linebreak in console/non-browser output.

The whole thing could be one-lined (including an additional space as I mentioned) thusly:
 

echo $data[$j] . ", <br>\n";

 

Link to comment
Share on other sites

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.