Jump to content
Pardon our ads (a necessary update) ×

Help with array- new line?


jacob1986

Recommended Posts

I have the following code (as below), but I cannot seem to make a new line (i,.e. 1: 1,2,3,4 and then make a new line with 3: 1,2,3,4). As it only prints 1: 1,2,3,4 3: 1,2,3,4

 - all I need is:

 

1: 1,2,3,4

3: 1,2,3,4

 

******************************************************

<?php
$array = array(
    1 => range (1, 4),
    2 => range (1, 4),
    3 => range (1, 4)
);

$numbers = count($array);
for ($i = 1; $i <= $numbers; $i += 2)  {
    echo $i . ': ' . implode(',', $array[$i]) . PHP_EOL;
}
?>

 

***************************************************************************

Link to comment
https://forums.phpfreaks.com/topic/299625-help-with-array-new-line/
Share on other sites

The PHP_EOL constant represents a newline character (e. g. the ASCII LF character on Linux). This only affects the source code of the HTML document. If you want to start a new line in your rendered document, you need an HTML line break element: <br>. Or better yet, use lists.

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.