Jump to content

Text formatting in ECHO


okrobie

Recommended Posts

Hello, I'm having trouble formatting the variables in this snippet. As you can see, I can format the first part of the text. Can someone please help?

{ 
echo ("<h3>Teachers Name: </h3>" . $row["first_name"]);
echo (" " . $row["last_name"]."<br>"."<br>");
echo nl2br("<h3>Teachers Message: </h3>" . $row["teacher"]."<br>"."<br>");
}

Link to comment
https://forums.phpfreaks.com/topic/200503-text-formatting-in-echo/
Share on other sites

Thank you, I was able to get it from what you gave me.

{ 
echo ("<h3>Teachers Name: </h3>" . "<h4>" . $row["first_name"] . "</h4>");
echo (" " . "<h4>" . $row["last_name"] ."</h4>" . "<br>"."<br>");
echo nl2br("<h3>Teachers Message: </h3>" . $row["teacher"]."<br>"."<br>");
}

echo does not require () braces, your also overdoing the concatenation. Your code could be simplified quite a bit.

 

echo "<h3>Teachers Name: </h3><h4>" . $row["first_name"] . "</h4>";
echo "<h4>" . $row["last_name"] . "</h4><br><br>";
echo "<h3>Teachers Message: </h3>" . nl2br($row["teacher"]) . "<br><br>";

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.