3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $lines = [ "1849781487", "1838433023", "1855575775", "1825054296", "1868575843", "1800003509", "1781354776", "1650813649", "1762706044", "1688111114", "1669462381", "1632164916" ]; $searchword = '18'; $matches = array(); foreach($lines as $k=>$v) { if(preg_match("/^$searchword/i", $v)) { $matches[$k] = $v; } } print_r($matches);
Output for 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.30 - 7.3.0alpha1
Array ( [0] => 1849781487 [1] => 1838433023 [2] => 1855575775 [3] => 1825054296 [4] => 1868575843 [5] => 1800003509 )