Re: FW: [PHP] String 2 Number
| From: | Andrey Hristov | Date: | Wed, 10 Oct 2001 11:50:10 +0000 |
| Subject: | Re: FW: [PHP] String 2 Number | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-70629@lists.php.net to get a copy of this message | ||
I think that $str+=0 is faster than sprintf
--
Andrey Hristov
Web Developer
IcyGEN Corporation
BALANCED SOLUTIONS
http://www.icygen.com
On Thursday 11 October 2001 05:54, you wrote:
> yah he's right...
> you can treat the string with the digits as number
>
> <?php
> $str = "3451";
> $num = $str + 1;
> ?>
>
> will result to 3452
>
> but if u still want... try this
>
> <?php
>
> $str = "3451";
> $num = sprintf("%d",$str);
>
> ?>
>
> hope that helps.
>
> jessie :)
>
> -----Original Message-----
> From: Dave Watkinson [mailto:d.watkinson@mightymatch.com]
> Sent: Wednesday, October 10, 2001 4:25 AM
> To: Saied Gerami; php-general@lists.php.net
> Subject: RE: [PHP] String 2 Number
>
>
> I don't think you need to - if it could be construed as a number PHP can
> treat it as such
>
> -----Original Message-----
> From: Saied Gerami [mailto:gerami@d21.de]
> Sent: 10 October 2001 12:31
> To: php-general@lists.php.net
> Subject: [PHP] String 2 Number
>
>
> Hi,
>
> Does anybody know how can I change a string containing only digits (like
> "3451") to number?
>
> Thanx,
>
> Saied