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){ $number = preg_replace('/^(\+)?\D+/', '', $t); print_r($number.PHP_EOL); }

preferences:
66.26 ms | 402 KiB | 5 Q