PDA

View Full Version : 0 at the beginning



hosdank
08-23-2008, 10:17 PM
I have a variable which has, let say the value of 1. I want to tack on a zero at the beginning so it has the value of 01. Thanks :)

techietim
08-23-2008, 10:17 PM
$var = '0' . $var;

Note, that will make it a string. If it gets changed back to an integer, the zero will be removed.

hosdank
08-23-2008, 10:22 PM
Yeah, thanks anyway, but I got it by myself... That's the very basics, I don't know how I forgot :o

Twey
08-24-2008, 12:06 AM
More generally, str_pad (http://www.php.net/str-pad)().