If I output the lines normally without everything is outputted on the same line in the source code which is not very nice looking.
So I'm wondering If there Is a fix for the problem at hand here.
The first line gets indented correctly but the lines coming after It gets stuck to the left wall without indentation as the code sample states below.
Source code:
<div><img u="image" src="images/Wooden_skull.jpg" /></div>
<div><img u="image" src="images/Lion.jpg" /></div>
<div><img u="image" src="images/cat.jpg" /></div>
<div><img u="image" src="images/Here_we_go.jpg" /></div>
<div><img u="image" src="images/ruined_building.jpg" /></div>
<div><img u="image" src="images/DSC_0184.JPG" /></div>
<div><img u="image" src="images/Dragon.jpg" /></div>
<div><img u="image" src="images/Punk_Tron.jpg" /></div>
<div><img u="image" src="images/Baby_viking.jpg" /></div>
PHP Code:
foreach($dbo->query($sql) as $row) {
$sliderimages .= '<div><img u="image" src="images/'.$row['image'].'" /></div>' . "
";
}
To create an indent in the source code (but not in the web page) in PHP, use \t
.
Using this:
foreach($dbo->query($sql) as $row) {
$sliderimages .= '\t\t<div><img u = "image" src = "images/' . $row['image'] .'" /></div>' . "
";
}
Should produce this output:
<div><img u = "image" src = "images/Wooden_skull.jpg" /></div>
<div><img u = "image" src = "images/Lion.jpg" /></div>
<div><img u = "image" src = "images/cat.jpg" /></div>
<div><img u = "image" src = "images/Here_we_go.jpg" /></div>
<div><img u = "image" src = "images/ruined_building.jpg" /></div>
<div><img u = "image" src = "images/DSC_0184.JPG" /></div>
<div><img u = "image" src = "images/Dragon.jpg" /></div>
<div><img u = "image" src = "images/Punk_Tron.jpg" /></div>
<div><img u = "image" src = "images/Baby_viking.jpg" /></div>