RE: [PHP] Leading zeroes

2002-05-24 Thread Ford, Mike [LSS]
> -Original Message- > From: Liam Gibbs [mailto:[EMAIL PROTECTED]] > Sent: 23 May 2002 18:49 > > > From version 4.1.0, $str = ltrim($str, '0') > > 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 em

RE: [PHP] Leading zeroes

2002-05-23 Thread Tom Rogers
Hi If it only a number in the string intval($str) should be enough to get rid of the zero unless it is only 0 Tom At 03:49 AM 24/05/2002, Liam Gibbs wrote: > > From version 4.1.0, $str = ltrim($str, '0') > >This works excellently. Thanks. One problem that I >didn't think of, though: If the num

RE: [PHP] Leading zeroes

2002-05-23 Thread Liam Gibbs
> I'm a newbie, but maybe this'll do it: > if ($str!='0') > { > $str = ltrim($str, '0') > } Duh. Sometimes I amaze myself at how stupid I can be. Thanks. :) __ Do You Yahoo!? LAUNCH - Your Yahoo! Music Experience http://launch.yahoo.com -- PHP G

Re: [PHP] Leading zeroes

2002-05-23 Thread Liam Gibbs
> Typecasting it to an integer will do what you want. > But only if your string is numbers only. There's no guarantee. Alphanumeric data is allowed. __ Do You Yahoo!? LAUNCH - Your Yahoo! Music Experience http://launch.yahoo.com -- PHP General

Re: [PHP] Leading zeroes

2002-05-23 Thread Chris Boget
> 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

RE: [PHP] Leading zeroes

2002-05-23 Thread ROBERT MCPEAK
I'm a newbie, but maybe this'll do it: if ($str!='0') { $str = ltrim($str, '0') } >>> Liam Gibbs <[EMAIL PROTECTED]> 05/23/02 01:49PM >>> > From version 4.1.0, $str = ltrim($str, '0') This works excellently. Thanks. One problem that I didn't think of, though: If the number is 0 (only 0), then t

RE: [PHP] Leading zeroes

2002-05-23 Thread Liam Gibbs
> From version 4.1.0, $str = ltrim($str, '0') 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

Re: [PHP] Leading zeroes

2002-05-23 Thread Rasmus Lerdorf
$str = ltrim($str,'0'); would be more efficient. On Thu, 23 May 2002, Michael Sims wrote: > On Thu, 23 May 2002 09:26:05 -0700 (PDT), you wrote: > > >Does anybody have a clever and efficient way of > >getting rid of leading zeroes in a string? > > How about: > > $str = preg_replace("/^0+/","",$

Re: [PHP] Leading zeroes

2002-05-23 Thread Michael Sims
On Thu, 23 May 2002 09:26:05 -0700 (PDT), you wrote: >Does anybody have a clever and efficient way of >getting rid of leading zeroes in a string? How about: $str = preg_replace("/^0+/","",$str); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.p

Re: [PHP] Leading zeroes

2002-05-23 Thread Chris Boget
> Does anybody have a clever and efficient way of > getting rid of leading zeroes in a string? If the string is completely numeric, you can do something like this: $string = "005847"; $string = (int)$string; Apart from that, you'll have to run it through some sort of regex, I suppose. Chris

RE: [PHP] Leading zeroes

2002-05-23 Thread Ford, Mike [LSS]
> -Original Message- > From: Liam Gibbs [mailto:[EMAIL PROTECTED]] > 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.ph