| Welcome to WebmasterWorld Guest from 22.214.171.124 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Become a Pro Member|
|Addition with php|
problem with zero's
I have a function that takes a var and adds 1
The problem is this:
The var starts as 01, I need to add 1 and have the output be 02 and so on untill 10 when the begining 0 will be dropped.
I am still new to PHP and some help with this one.
This is what I am using now:
<? $new-var = $some-var + 01 ?>
Thanks in advance,
Test to see if $newvar is less then 2 digits.
$newvar = "0" . $newvar;
That did the trick.
$var = sprintf [php.net]("%02d", $var);
would work as well.
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved