preg_replace() ?
Posted: Wed Apr 12, 2006 9:21 am
Should I use preg_replace to search for symbols I don't like in a string?
I was wondering if there is a way I can get just those 10 digits only so I don't have to go each string?
Code: Select all
$a=1234567891@mail.com
$b=a b 9876543210
$c=1-1234567890
$d=123-456-7891
$a=preg_replace('/\s+/', '', trim(a));
$a=preg_replace('1-', '',$a);
$a=preg_replace('(', '',$a);
$a=preg_replace(')', '',$a);
$a=preg_replace('@mail.com', '',$a);
$a=preg_replace('@', '',$a);
$a=preg_replace('.', '',$a);