3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 .= "((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 4.3.4 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
string(17) "\/((text)|(some))" int(2) array(4) { [0]=> array(2) { [0]=> string(5) "/some" [1]=> string(5) "/text" } [1]=> array(2) { [0]=> string(4) "some" [1]=> string(4) "text" } [2]=> array(2) { [0]=> string(0) "" [1]=> string(4) "text" } [3]=> array(2) { [0]=> string(4) "some" [1]=> string(0) "" } } array(4) { [0]=> string(5) "/some" [1]=> string(4) "some" [2]=> bool(false) [3]=> string(4) "some" } array(4) { [0]=> string(5) "/text" [1]=> string(4) "text" [2]=> string(4) "text" [3]=> bool(false) }
Output for 4.3.2 - 4.3.3
Warning: mb_convert_encoding(): Illegal character encoding specified in /in/aCWSe on line 10 Warning: mb_convert_encoding(): Unknown encoding "Windows-1251" in /in/aCWSe on line 12 string(15) "((text)|(some))" int(2) array(4) { [0]=> array(2) { [0]=> string(4) "some" [1]=> string(4) "text" } [1]=> array(2) { [0]=> string(4) "some" [1]=> string(4) "text" } [2]=> array(2) { [0]=> string(0) "" [1]=> string(4) "text" } [3]=> array(2) { [0]=> string(4) "some" [1]=> string(0) "" } } Fatal error: Call to undefined function: mb_regex_encoding() in /in/aCWSe 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/aCWSe on line 10 Warning: mb_convert_encoding() [http://www.php.net/function.mb-convert-encoding]: Unknown encoding "Windows-1251" in /in/aCWSe on line 12 string(15) "((text)|(some))" int(2) array(4) { [0]=> array(2) { [0]=> string(4) "some" [1]=> string(4) "text" } [1]=> array(2) { [0]=> string(4) "some" [1]=> string(4) "text" } [2]=> array(2) { [0]=> string(0) "" [1]=> string(4) "text" } [3]=> array(2) { [0]=> string(4) "some" [1]=> string(0) "" } } Fatal error: Call to undefined function: mb_regex_encoding() in /in/aCWSe on line 23