3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $nationalNumber = "4732691234"; $nationalNumberPattern = '[4589]\d{9}'; $final_pattern = '(?:' . $nationalNumberPattern . ')'; $final_pattern = '^' . $final_pattern . '$'; $final_pattern = '/' . $final_pattern . '/x'; $b = (preg_match($final_pattern, $nationalNumber, $groups, PREG_OFFSET_CAPTURE) == 1) ? true : false; var_dump($final_pattern, $nationalNumber, $b, $groups);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
string(20) "/^(?:[4589]\d{9})$/x" string(10) "4732691234" bool(true) array(1) { [0]=> array(2) { [0]=> string(10) "4732691234" [1]=> int(0) } }