3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = <<<TXT /some /text / TXT; $pattern = "/"; $pattern = mb_convert_encoding($pattern, 'UTF-8', 'Windows-1251'); $pattern = preg_quote($pattern, '/'); $pattern = mb_convert_encoding($pattern, 'Windows-1251', 'UTF-8'); $pattern .= "(?<namedS>text|some)"; var_dump($pattern); $matches = array(); $match = preg_match_all("/" . $pattern . "/mi", $text, $matches); var_dump($match, $matches); mb_regex_encoding('UTF-8'); mb_ereg_search_init($text); while(mb_ereg_search("" . $pattern, "imz")) { $r = mb_ereg_search_getregs(); mb_ereg_search_setpos(mb_ereg_search_getpos()); var_dump($r); }
Output for 7.4.8 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
string(22) "\/(?<namedS>text|some)" int(2) array(3) { [0]=> array(2) { [0]=> string(5) "/some" [1]=> string(5) "/text" } ["namedS"]=> array(2) { [0]=> string(4) "some" [1]=> string(4) "text" } [1]=> array(2) { [0]=> string(4) "some" [1]=> string(4) "text" } } Warning: mb_ereg_search(): mbregex compile err: undefined group option in /in/eau0N on line 26
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.7
string(22) "\/(?<namedS>text|some)" int(2) array(3) { [0]=> array(2) { [0]=> string(5) "/some" [1]=> string(5) "/text" } ["namedS"]=> array(2) { [0]=> string(4) "some" [1]=> string(4) "text" } [1]=> array(2) { [0]=> string(4) "some" [1]=> string(4) "text" } } array(3) { [0]=> string(5) "/some" [1]=> string(4) "some" ["namedS"]=> string(4) "some" } array(3) { [0]=> string(5) "/text" [1]=> string(4) "text" ["namedS"]=> string(4) "text" }
Output for 5.2.2 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.30, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33
string(22) "\/(?<namedS>text|some)" int(2) array(3) { [0]=> array(2) { [0]=> string(5) "/some" [1]=> string(5) "/text" } ["namedS"]=> array(2) { [0]=> string(4) "some" [1]=> string(4) "text" } [1]=> array(2) { [0]=> string(4) "some" [1]=> string(4) "text" } } array(2) { [0]=> string(5) "/some" [1]=> string(4) "some" } array(2) { [0]=> string(5) "/text" [1]=> string(4) "text" }
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.1, 5.1.3 - 5.1.6, 5.2.0 - 5.2.1
string(22) "\/(?<namedS>text|some)" Warning: preg_match_all(): Compilation failed: unrecognized character after (?< at offset 5 in /in/eau0N on line 19 bool(false) array(0) { } array(2) { [0]=> string(5) "/some" [1]=> string(4) "some" } array(2) { [0]=> string(5) "/text" [1]=> string(4) "text" }
Output for 5.1.2
string(22) "\/(?<namedS>text|some)" Warning: preg_match_all(): Compilation failed: unrecognized character after (?< at offset 5 in /in/eau0N on line 20 bool(false) array(0) { } array(2) { [0]=> string(5) "/some" [1]=> string(4) "some" } array(2) { [0]=> string(5) "/text" [1]=> string(4) "text" }
Output for 4.4.6 - 4.4.9
string(22) "\/(?<namedS>text|some)" int(2) array(3) { [0]=> array(2) { [0]=> string(5) "/some" [1]=> string(5) "/text" } ["namedS"]=> array(2) { [0]=> string(4) "some" [1]=> string(4) "text" } [1]=> array(2) { [0]=> string(4) "some" [1]=> string(4) "text" } } Warning: mb_ereg_search(): mbregex compile err: undefined (?...) sequence in /in/eau0N on line 26
Output for 4.3.11, 4.4.0 - 4.4.1, 4.4.3 - 4.4.5
string(22) "\/(?<namedS>text|some)" Warning: preg_match_all(): Compilation failed: unrecognized character after (?< at offset 5 in /in/eau0N on line 19 bool(false) array(0) { } Warning: mb_ereg_search(): mbregex compile err: undefined (?...) sequence in /in/eau0N on line 26
Output for 4.4.2
string(22) "\/(?<namedS>text|some)" Warning: preg_match_all(): Compilation failed: unrecognized character after (?< at offset 5 in /in/eau0N on line 20 bool(false) array(0) { } Warning: mb_ereg_search(): mbregex compile err: undefined (?...) sequence in /in/eau0N on line 27
Output for 4.3.4 - 4.3.10
string(22) "\/(?<namedS>text|some)" Warning: Compilation failed: unrecognized character after (?< at offset 5 in /in/eau0N on line 19 bool(false) array(0) { } Warning: mb_ereg_search(): mbregex compile err: undefined (?...) sequence in /in/eau0N on line 26
Output for 4.3.2 - 4.3.3
Warning: mb_convert_encoding(): Illegal character encoding specified in /in/eau0N on line 10 Warning: mb_convert_encoding(): Unknown encoding "Windows-1251" in /in/eau0N on line 12 string(20) "(?<namedS>text|some)" Warning: Compilation failed: unrecognized character after (?< at offset 3 in /in/eau0N on line 19 bool(false) array(0) { } Fatal error: Call to undefined function: mb_regex_encoding() in /in/eau0N on line 23
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: mb_convert_encoding() [http://www.php.net/function.mb-convert-encoding]: Illegal character encoding specified in /in/eau0N on line 10 Warning: mb_convert_encoding() [http://www.php.net/function.mb-convert-encoding]: Unknown encoding "Windows-1251" in /in/eau0N on line 12 string(20) "(?<namedS>text|some)" Warning: Compilation failed: unrecognized character after (?< at offset 3 in /in/eau0N on line 19 bool(false) array(0) { } Fatal error: Call to undefined function: mb_regex_encoding() in /in/eau0N on line 23

preferences:
237.23 ms | 402 KiB | 386 Q