Re: [PHP] excluding parenthesis, space and dashes from phone number
- From: znemeth@xxxxxxxxxxxxxx (Zoltán Németh)
- Date: Fri, 30 Nov 2007 15:54:56 +0100
2007. 11. 30, péntek keltezéssel 08.44-kor afan pasalic ezt írta:
hi,
I store phone number in mysql as integer, e.g. (123) 456-7890 is stored
as 1234567890.
though, in search form they usually type in a phone number with
parenthesis/space/dashes. I have to extract numbers before I search
through mysql.
currently, I use eregi_replace() function, several times, to do the job:
eregi_replace(' ', '', $phone);
eregi_replace('(', '', $phone);
eregi_replace(')', '', $phone);
eregi_replace('-', '', $phone);
and it works fine.
but, is there any better way? more "fancy"? :)
str_replace would do the job.
http://hu2.php.net/str_replace
$phone = str_replace(array(' ','(',')','-'), '', $phone);
greets
Zoltán Németh
.
thanks for any help.
-afan
- References:
- excluding parenthesis, space and dashes from phone number
- From: afan pasalic
- excluding parenthesis, space and dashes from phone number
- Prev by Date: Re: [PHP] excluding parenthesis, space and dashes from phone number
- Next by Date: Re: [PHP] PHP RFC # 0001 --- List Etiquette
- Previous by thread: Re: [PHP] excluding parenthesis, space and dashes from phone number
- Next by thread: RE: [PHP] including parenthesis, space and dashes in a phone number
- Index(es):
Relevant Pages
|