Re: Re: data type casting to numbers with intval() or doubleval()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



> I think a regex would be most appropriate here:
> 
> <?php
> 
> $my_string = "mmm444";
> 
> $my_integer = intval(eregi_replace("[a-z]", "", $my_string));
> 
> print $my_integer;
> 
> ?>
> 
> This removes all letters and takes the int value.  In perl you can remove
> everything that's NOT a digit but I didn't figure that out in PHP yet...  this
> should do for now.

you're thinking of something like:

 $my_integer = intval(preg_replace('!\D+!', '', $my_string));

aren't you?

PCRE regular expression finctions are PERL compatible reg. functions 
using PCRE library.



[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux