Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to echo without line breaks in php?

How do i echo all array elements in a single line whitout line breaks on every itteration though the array? This is the code i was able to come up with but it prints every element on a new line.

while($row = mysql_fetch_assoc($result))
{
    echo '<h3> Some text'. $row['user_name'] . '</h3>';
}
like image 781
user1908599 Avatar asked Jan 14 '23 18:01

user1908599


2 Answers

h3 is a block element. You can make it display in line by not using h3 (use span maybe) or styling it to be inline:

CSS:

h3 {
    display: inline;
}
like image 160
sachleen Avatar answered Jan 17 '23 16:01

sachleen


That's because <h3>, like other <hx> tags are block level elements, and so will render on their own line. You either use an inline element, like <span> or set the display property of the <h3> tag to display: inline in the CSS.

like image 43
thescientist Avatar answered Jan 17 '23 18:01

thescientist