Hello,
I'm running a script that intake 07 as valid number not 7.
How can I convert 7 to 07.
Thanks In advance,
Regards,
Kevin
| SitePoint Sponsor |
Hello,
I'm running a script that intake 07 as valid number not 7.
How can I convert 7 to 07.
Thanks In advance,
Regards,
Kevin
$variable = "0$variable";
Guido - Community Team Advisor
Do you know where the (database) error is? Add it to the list!
Thinking Web: Voices of the Community
Blog - Free Flash Slideshow Widget
Maybe this post about adding zero's could also help.



you can also use
$number_formatted=sprintf("%02d",$variable );
sprintf return the formatted string.
http://pritisolanki.blogspot.com/ - Learning Excellence
http://pritisolanki.wordpress.com/ -Sharing Opportunities
http://www.php.net/manual/en/function.sprintf.php
Look at example 7.
It adds zeroes in front of the variable, until it's at least two characters long. So '7' will become '07', and '07' would remain '07'.
Guido - Community Team Advisor
Do you know where the (database) error is? Add it to the list!
Thinking Web: Voices of the Community
Blog - Free Flash Slideshow Widget
Bookmarks