Page 1 of 1

take out dashes from telephone

Posted: Mon Jul 26, 2004 4:56 am
by gurjit
Hi all,

i have a field with mixed telephone formats i need to takeout the

- dashes
- any alpha characters
- align the number to the left with dashes and spaces taken out

how can i do this using preg_replace.

I tried this but it never worked

Code: Select all

<?php
preg_replace( "%[^0-9]%", "", $TELEPHONE );
?>

Posted: Mon Jul 26, 2004 6:45 am
by Weirdan

Code: Select all

$phone = preg_replace("/[^0-9]/", "", $phone);