Page 1 of 1

Printf command printing unwanted carriage return

Posted: Thu Aug 30, 2007 2:40 am
by Percipient
I have a very small segment of code that's been bothering me for a while but not enough for me to really do anything about it until now.

My problem is, I'm using a printf command to print a formatted decimal, but there's an unwanted carriage return (two, actually) in there, so instead of getting
"Number: [5.02]"
I get
"Number:[
5.02
]"

using essentially the code below

Code: Select all

<? echo("Number: ["); 
?><div id="blah"><?
						printf('%03.1f',($test));
?></div><? echo(']'); ?>
I made sure to get rid of white spaces in between the ending php tag and the html div's just in case....I'm figuring it's something with printf that inserts a carriage return like that by default. Is there some way to disable or counteract this?

Any help appreciated, thanks!

--Tony

Posted: Thu Aug 30, 2007 2:51 am
by VladSun
It is not a printf() error, it is an HTML error ;)

DIV is block element, not inline. Use SPAN.

Posted: Fri Aug 31, 2007 1:28 pm
by Weirdan
DIV is block element...
... thus it visually starts on a new line
It is not a printf() error, it is an HTML error
Not an error per se, actually.