3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $numbers = ["12345", "12346", "12347", "12398"]; $input = "12398"; $arr = preg_grep("/". substr($input,0,3) . "/", $numbers); Var_dump($arr);
based on EWDCo
Output for 5.6.38 - 7.3.0rc3
array(4) { [0]=> string(5) "12345" [1]=> string(5) "12346" [2]=> string(5) "12347" [3]=> string(5) "12398" }