0

How to keep this code result on single line (no split). The result is displayed on a table and the column width is splitting the result in two lines. How to keep the output on single line? How to use the echo to fix that problem? Thank you!

$price = sprintf("%0.2f", $price); 

$parts = explode('.', $price);

echo "$parts[0] <span style = 'font-color: #ff0000; font-size:12px'><sup> ,$parts[1] USD</sup></span>";

enter image description here

1

2 Answers 2

2

You can prevent wrapping of text by using the white-space property in css:

http://www.w3schools.com/cssref/pr_text_white-space.asp

1
  • Problem fixed: echo "$parts[0]<span style = 'white-space: nowrap; font-color: #ff0000;font-size:12px'><sup> ,$parts[1] USD</sup></span>";
    – Marius
    Feb 20, 2015 at 5:58
1

I'm not a fan of inline styles like this but you could try adding a width to it.

echo "<span style='width:120px'>$parts[0] <span style = 'font-color: #ff0000; font-size:12px;'><sup> ,$parts[1] USD</sup></span></span>";
2
  • It is not working.
    – Marius
    Feb 20, 2015 at 5:16
  • @Ben Robie's answer is correct. Feb 20, 2015 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.