Skip site navigation (1) Skip section navigation (2)

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

From: "Papp Gyozo" <pgerzson(at)freestart(dot)hu>
To: "Wesley Leonard" <marshall(at)pacdemon(dot)org>, <beloshapka(at)mnogo(dot)ru>
Cc: <pgsql-php(at)postgresql(dot)org>
Subject: Re: Re: data type casting to numbers with intval() or doubleval()
Date: 2001-11-16 07:15:06
Message-ID: 023601c16ea8$4c4c1460$01fdfea9@jaguar (view raw or flat)
Thread:
Lists: pgsql-php
> 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.


In response to

pgsql-php by date

Next:From: speedboyDate: 2001-11-16 07:41:34
Subject: Re: Re: Secure pages
Previous:From: PeterDate: 2001-11-16 05:50:42
Subject: Re: Wildcard queries via PHP4

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group