3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ReformatPhoneNumber($number) { $isValid = preg_match('/^(\d[ |-]*){6,11}\d$/i', $number, $result); if(!$isValid) { //throw new Exception('Division by zero.'); } return str_replace(array(' ' , '-'), array('', ''), $number); }

preferences:
38.02 ms | 402 KiB | 5 Q