Page 1 of 1
Making 0-9 display as 00-09 ?
Posted: Tue Sep 23, 2003 11:07 pm
by Pyrite
The subject says it all. Looked through the PHP manual, couldn't find any functions really. If I do something like if $foo <10, $foo = "0".$foo; it still shows up without the 0 in front.
Also had a question about tabs.
if I echo some and put a \t in it, it puts the tab in the code when I view source, but not when echoed. Is there a HTML tag for tab or a php way to tab. echoing " " doesn't do the trick.
Thanks!
Posted: Tue Sep 23, 2003 11:18 pm
by Leviathan
Just like C/C++:
%d means print a decimal; putting 02 means 2-digit 0-padded. Check the documentation for sprintf if you want to find out more about format strings.
Posted: Tue Sep 23, 2003 11:30 pm
by Pyrite
That did it! Thank you. I would have thought of that if I had ever used C, but I've only had some C++ and we used cout

Posted: Wed Sep 24, 2003 5:38 am
by twigletmac
About tabs - if you need tabs to appear you either have to replace them with no-breaking whitespaces, use CSS to add a margin to the text or show the text within <pre> tags. Personally, I'd probably go the CSS route, but it does depend on what needs to be displayed.
Mac
Posted: Wed Sep 24, 2003 12:22 pm
by Pyrite
Well, I tried doing the <pre> tags thing, that didn't work though for me. Instead I put the things in the quotes with the printf function and that did it. I just basically wanted to display what I was printf'ing over a tab or two.