Jump to content

How to put line break in this PHP code, and echo dollar signs


AKmiecik

Recommended Posts

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...

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*

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!

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.