3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = array( '+380671072122','+3 80671072122','+3 8 067 107 21 22','+38(067)1072122','+38 (067) 107 21 22','+3 8067 107-21-22','067 107 21 22','067-107-21-22' ); foreach($test as $t){ preg_match('/^(\+?\d{1})?\s*(\(\d+\))?[\s-]*([\d-]*)$/', $t, $number); print_r($number); }

preferences:
37.92 ms | 402 KiB | 5 Q