Re: Re: php4 vs. php5
| From: | Rory Browne | Date: | Fri, 03 Feb 2006 17:10:03 +0000 |
| Subject: | Re: Re: php4 vs. php5 | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-229820@lists.php.net to get a copy of this message | ||
On 2/3/06, Keith Proctor <keith_proctor@filemaker.com> wrote:
> I need to add two numbers together, unfortunately one of them is a
> string that starts with a character. I'd like to convert a string
> such as 'x5' to the number 5. Don't care about it's final type as
> that isn't the hard part. :) I can't find a function to do this. I
> looked in the math class and in the string class and there doesn't
> seem to be something to help. I, of course, could write something to
> handle it but I would prefer to use something built in. Any help
> would be appreciated.
preg_replace("/[^0-9]/", "", $x)
I would expect intval to work as well, but aparently not.