nick5449 Posted July 5, 2006 Share Posted July 5, 2006 I have an array that I want to display, but with a enter in between them. The code I have is this: [code] $x = 0; while($x != count($test)){ echo $test[$x]; echo "\n"; $x++; }[/code]The array is displayed but the enter isn't. Why wont '\n' work and how else can I get an enter to be displayed? Thanks. Link to comment https://forums.phpfreaks.com/topic/13789-spacing-problems/ Share on other sites More sharing options...
kenrbnsn Posted July 5, 2006 Share Posted July 5, 2006 Web browsers do not display "\n" as a line break, you need to output the [code]<br>[/code] tag for that.Ken Link to comment https://forums.phpfreaks.com/topic/13789-spacing-problems/#findComment-53579 Share on other sites More sharing options...
Orio Posted July 5, 2006 Share Posted July 5, 2006 A suggestion for you nick, you can make your script shorter using "foreach":[code]<?phpforeach($test as $value){echo($val."<br>");}?>[/code][hr]Orio. Link to comment https://forums.phpfreaks.com/topic/13789-spacing-problems/#findComment-53581 Share on other sites More sharing options...
SharkBait Posted July 5, 2006 Share Posted July 5, 2006 <br /> for break but you could do it like[code]<?phpwhile($x != count($test)) { echo $test[$x] ." <br /><br />"; $x++;}// orwhile ($x != count($test)) { echo "<p>{$test[$x]}</p>";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/13789-spacing-problems/#findComment-53582 Share on other sites More sharing options...
nogray Posted July 5, 2006 Share Posted July 5, 2006 you can use [url=http://us2.php.net/manual/en/function.implode.php]implode()[/url] to do this[code]echo implode("<br />", $test);[/code] Link to comment https://forums.phpfreaks.com/topic/13789-spacing-problems/#findComment-53585 Share on other sites More sharing options...
nick5449 Posted July 5, 2006 Author Share Posted July 5, 2006 Awesome, that helps a lot. Thanks for the suggestions. Link to comment https://forums.phpfreaks.com/topic/13789-spacing-problems/#findComment-53586 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.