RE: [PHP] Leading zeroes
| From: | Ford, Mike [LSS] | Date: | Thu, 23 May 2002 16:54:44 +0000 |
| Subject: | RE: [PHP] Leading zeroes | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-98942@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Liam Gibbs [mailto:liamgibbs@yahoo.com]
> Sent: 23 May 2002 17:26
>
> Does anybody have a clever and efficient way of
> getting rid of leading zeroes in a string?
From version 4.1.0, $str = ltrim($str, '0') (see http://www.php.net/manual/en/function.ltrim.php).
For older versions, how about:
$str = substr($str, strspn($str, '0'));
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211