Re: Leading zeroes
| From: | Chris Boget | Date: | Thu, 23 May 2002 17:55:41 +0000 |
| Subject: | Re: Leading zeroes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-98960@lists.php.net to get a copy of this message | ||
> This works excellently. Thanks. One problem that I
> didn't think of, though: If the number is 0 (only 0),
> then the string ends up being empty. Is there a way
> around that? I put an if statement in saying if the
> string is empty, then the string is 0. Any better way?
Again, if the string is numbers only, you can do:
$string = "0";
$string = (int)$string;
Typecasting it to an integer will do what you want. But only
if your string is numbers only.
Chris