3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $txt = '<div id="5">'; preg_match('`\s+([\w-]+)="([^"]*)"`', $txt, $match); var_dump($match); preg_match('`\s+(?P<key>[\w-]+)="(?P<value>[^"]*)"`', $txt, $match); var_dump($match); preg_match('`\s+(?<key>[\w-]+)="(?<value>[^"]*)"`', $txt, $match); var_dump($match);
Output for 4.4.6 - 4.4.9, 5.2.2 - 5.6.30, hhvm-3.10.1 - 3.17.3, 7.0.0 - 7.3.0rc3
array(3) { [0]=> string(7) " id="5"" [1]=> string(2) "id" [2]=> string(1) "5" } array(5) { [0]=> string(7) " id="5"" ["key"]=> string(2) "id" [1]=> string(2) "id" ["value"]=> string(1) "5" [2]=> string(1) "5" } array(5) { [0]=> string(7) " id="5"" ["key"]=> string(2) "id" [1]=> string(2) "id" ["value"]=> string(1) "5" [2]=> string(1) "5" }
Output for 5.2.0 - 5.2.1
array(3) { [0]=> string(7) " id="5"" [1]=> string(2) "id" [2]=> string(1) "5" } array(5) { [0]=> string(7) " id="5"" ["key"]=> string(2) "id" [1]=> string(2) "id" ["value"]=> string(1) "5" [2]=> string(1) "5" } Warning: preg_match(): Compilation failed: unrecognized character after (?< at offset 6 in /in/HYM0M on line 7 array(5) { [0]=> string(7) " id="5"" ["key"]=> string(2) "id" [1]=> string(2) "id" ["value"]=> string(1) "5" [2]=> string(1) "5" }
Output for 4.3.11 - 4.4.5, 5.0.0 - 5.1.6
array(3) { [0]=> string(7) " id="5"" [1]=> string(2) "id" [2]=> string(1) "5" } array(5) { [0]=> string(7) " id="5"" ["key"]=> string(2) "id" [1]=> string(2) "id" ["value"]=> string(1) "5" [2]=> string(1) "5" } Warning: preg_match(): Compilation failed: unrecognized character after (?< at offset 6 in /in/HYM0M on line 7 array(0) { }
Output for 4.3.3 - 4.3.10
array(3) { [0]=> string(7) " id="5"" [1]=> string(2) "id" [2]=> string(1) "5" } array(5) { [0]=> string(7) " id="5"" ["key"]=> string(2) "id" [1]=> string(2) "id" ["value"]=> string(1) "5" [2]=> string(1) "5" } Warning: Compilation failed: unrecognized character after (?< at offset 6 in /in/HYM0M on line 7 array(0) { }
Output for 4.3.0 - 4.3.2
array(3) { [0]=> string(7) " id="5"" [1]=> string(2) "id" [2]=> string(1) "5" } array(3) { [0]=> string(7) " id="5"" [1]=> string(2) "id" [2]=> string(1) "5" } Warning: Compilation failed: unrecognized character after (?< at offset 6 in /in/HYM0M on line 7 array(0) { }