3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $sub = array( '+7812-703-10-00', '8-812-346-60-01', '+7(495)785-98-42', '(499) 725 77 88', '8 (495) 663-61-00', '(812) 448-54-18', '8916-318-36-36', '540-69-05' ); foreach($sub as $s){ preg_match('/^(\+?\d+)?\s*(\(\d+\))?[\s-]*([\d-]*)$/', $s, $res); print_r($res); }
Output for 4.3.0 - 7.1.0
Array ( [0] => +7812-703-10-00 [1] => +7812 [2] => [3] => 703-10-00 ) Array ( [0] => 8-812-346-60-01 [1] => 8 [2] => [3] => 812-346-60-01 ) Array ( [0] => +7(495)785-98-42 [1] => +7 [2] => (495) [3] => 785-98-42 ) Array ( ) Array ( [0] => 8 (495) 663-61-00 [1] => 8 [2] => (495) [3] => 663-61-00 ) Array ( [0] => (812) 448-54-18 [1] => [2] => (812) [3] => 448-54-18 ) Array ( [0] => 8916-318-36-36 [1] => 8916 [2] => [3] => 318-36-36 ) Array ( [0] => 540-69-05 [1] => 540 [2] => [3] => 69-05 )