When I output a list in php I always get the following format....
<li class="arrow"><a href="#210502">Adidas Sports Performance</a></li><li class="arrow"><a href="#200092">Aedes De Venustas</a></li><li class="arrow"><a href="#210111">African Paradise</a></li><li class="arrow"><a href="#210236">Agata & Valentina</a></li>
With all the code on one line. How can I force it to display like this in the code instead....
<li class="arrow"><a href="#210502">Adidas Sports Performance</a></li>
<li class="arrow"><a href="#200092">Aedes De Venustas</a></li>
<li class="arrow"><a href="#210111">African Paradise</a></li>
<li class="arrow"><a href="#210236">Agata & Valentina</a></li>
Is there something I can find and replace in the code after input to force a line break. A line break in the code only, obviously it will show on separate lines when viewed on the web.
Code line breaks
Moderator: General Moderators
Re: Code line breaks
i'm not sure about the php code for this because i never did it before.
but it seems like you want the line breaks after </li>
if you already know how to do find/replace just search for "</li>" and replace with "</li><br>" or "</li>\n" or whatever you want to do...
but it seems like you want the line breaks after </li>
if you already know how to do find/replace just search for "</li>" and replace with "</li><br>" or "</li>\n" or whatever you want to do...
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Code line breaks
You can put physical line breaks like:
Or you can add the newline character \n
Code: Select all
echo '<li class="arrow"><a href="#210502">Adidas Sports Performance</a></li>
<li class="arrow"><a href="#200092">Aedes De Venustas</a></li>';mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
- hypedupdawg
- Forum Commoner
- Posts: 74
- Joined: Sat Apr 10, 2010 5:21 am
Re: Code line breaks
Yes, I agree with AbraCadaver:
Will give you what you want. Any whitespace inside the string is saved in php. So the source code will look like this.
Code: Select all
<?php
$i = 1;
while ($i < 5)
{
print "This is line " . $i . "<br/>
";
$i++;
}
?>Code: Select all
<body>
<p>
This is line 1<br/>
This is line 2<br/>
This is line 3<br/>
This is line 4<br/>
</p>
</body>Re: Code line breaks
Thanks I'll give those a try.