3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php preg_match_all('~([a-z])([0-9])~', 'b53d34a32', $matches); var_dump($matches); print str_repeat('=-', 42); preg_match_all('~([a-z])([0-9])~', 'b53d34a32', $matches, PREG_OFFSET_CAPTURE); var_dump($matches);
Output for 4.3.3 - 7.1.0
array(3) { [0]=> array(3) { [0]=> string(2) "b5" [1]=> string(2) "d3" [2]=> string(2) "a3" } [1]=> array(3) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "a" } [2]=> array(3) { [0]=> string(1) "5" [1]=> string(1) "3" [2]=> string(1) "3" } } =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-array(3) { [0]=> array(3) { [0]=> array(2) { [0]=> string(2) "b5" [1]=> int(0) } [1]=> array(2) { [0]=> string(2) "d3" [1]=> int(3) } [2]=> array(2) { [0]=> string(2) "a3" [1]=> int(6) } } [1]=> array(3) { [0]=> array(2) { [0]=> string(1) "b" [1]=> int(0) } [1]=> array(2) { [0]=> string(1) "d" [1]=> int(3) } [2]=> array(2) { [0]=> string(1) "a" [1]=> int(6) } } [2]=> array(3) { [0]=> array(2) { [0]=> string(1) "5" [1]=> int(1) } [1]=> array(2) { [0]=> string(1) "3" [1]=> int(4) } [2]=> array(2) { [0]=> string(1) "3" [1]=> int(7) } } }
Output for 4.3.0 - 4.3.2
array(3) { [0]=> array(3) { [0]=> string(2) "b5" [1]=> string(2) "d3" [2]=> string(2) "a3" } [1]=> array(3) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "a" } [2]=> array(3) { [0]=> string(1) "5" [1]=> string(1) "3" [2]=> string(1) "3" } } =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Warning: Wrong value for parameter 4 in call to preg_match_all() in /in/Oaoa1 on line 8 array(3) { [0]=> array(3) { [0]=> string(2) "b5" [1]=> string(2) "d3" [2]=> string(2) "a3" } [1]=> array(3) { [0]=> string(1) "b" [1]=> string(1) "d" [2]=> string(1) "a" } [2]=> array(3) { [0]=> string(1) "5" [1]=> string(1) "3" [2]=> string(1) "3" } }