AKmiecik Posted April 30, 2009 Share Posted April 30, 2009 How do I put line breaks (so Descript1b, 1c and 1d are on different lines) in the following code: <?php echo "<td class=\"{$class1}\">"; echo $info["Descript1a"]; echo $info["Descript1b"]; echo $info["Descript1c"]; echo $info["Descript1d"]; ?><!-- Col 2 --> I tried <br />, "<br /">, \r\n and various other thinks, thanks.... Also, the descript field has a dollar sign that does not print out, how do I do that too... Quote Link to comment https://forums.phpfreaks.com/topic/156271-how-to-put-line-break-in-this-php-code-and-echo-dollar-signs/ Share on other sites More sharing options...
Ken2k7 Posted April 30, 2009 Share Posted April 30, 2009 Add in a <br />. <?php echo "<td class=\"{$class1}\">" . $info["Descript1a"] . "<br />" . $info["Descript1b"] . "<br />" . $info["Descript1c"] . "<br />" . $info["Descript1d"]; ?><!-- Col 2 --> Edit: With so many <br />s, I should have used a delimited print function. *sighs* Quote Link to comment https://forums.phpfreaks.com/topic/156271-how-to-put-line-break-in-this-php-code-and-echo-dollar-signs/#findComment-822673 Share on other sites More sharing options...
Adam Posted April 30, 2009 Share Posted April 30, 2009 Try... <?php echo "<td class=\"{$class1}\">"; echo $info["Descript1a"] . '<br />'; echo $info["Descript1b"] . '<br />'; echo $info["Descript1c"] . '<br />'; echo $info["Descript1d"] . '<br />'; ?> <!-- Col 2 --> Which 'descript' field do you mean? If it's (for example) 'Descript1a' you can use: echo str_replace('$', '& #36;', $info["Descript1a"]) . '<br />'; Or to apply to them all you could use something like: foreach ($info as $key => $val) { $info[$key] = str_replace('$', '& #36;', $val); } Edit: The html entities shouldn't have a space after the ampersand though! Quote Link to comment https://forums.phpfreaks.com/topic/156271-how-to-put-line-break-in-this-php-code-and-echo-dollar-signs/#findComment-822677 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.