3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $input = 'S1G5AB'; // given this $store = '5I6GAB'; // actually this $regex = str_split($input); /* $regex = implode('', array_map( function ($char) { echo $char; return $char; static $map = ['S'=>'[S5]','5'=>'[S5]','1'=>'[1I]','I'=>'[1I]','G'=>'[6G]','6'=>'[6G]']; return array_key_exists($char, $map) ? $map[$char] : $char; }. [ 'a', 'b' ] // str_split($input) )); */ var_dump($regex); echo $regex . PHP_EOL; echo (0 < preg_match("/$regex/", $store) ? 'Match' : 'No match');
based on bqtuA
Output for 5.4.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(6) { [0]=> string(1) "S" [1]=> string(1) "1" [2]=> string(1) "G" [3]=> string(1) "5" [4]=> string(1) "A" [5]=> string(1) "B" } Notice: Array to string conversion in /in/o4nIE on line 18 Array Notice: Array to string conversion in /in/o4nIE on line 19 No match
Output for 5.0.2 - 5.3.29
array(6) { [0]=> string(1) "S" [1]=> string(1) "1" [2]=> string(1) "G" [3]=> string(1) "5" [4]=> string(1) "A" [5]=> string(1) "B" } Array No match
Output for 5.0.0 - 5.0.1
array(6) { [0]=> string(1) "S" [1]=> string(1) "1" [2]=> string(1) "G" [3]=> string(1) "5" [4]=> string(1) "A" [5]=> string(1) "B" } Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/o4nIE on line 18 ArrayPHP_EOLNo match
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: str_split() in /in/o4nIE on line 5
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: str_split() in /in/o4nIE on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: str_split() in /in/o4nIE on line 5