@ 2014-08-13T03:40:05Z <?php
$input = 'S1G5AB'; // given this
$store = '5I6GAB'; // actually this
$regex = array_map('trim', 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');
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 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"
}
Warning: Array to string conversion in /in/VJfiA on line 18
Array
Warning: Array to string conversion in /in/VJfiA on line 19
No match Output for 5.4.0 - 5.4.45 , 5.5.24 - 5.5.35 , 5.6.8 - 5.6.28 , 7.0.0 - 7.0.20 , 7.1.0 - 7.1.25 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.31 , 7.4.0 - 7.4.33 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/VJfiA on line 18
Array
Notice: Array to string conversion in /in/VJfiA on line 19
No match Output for 5.0.2 - 5.0.5 , 5.1.0 - 5.1.6 , 5.2.0 - 5.2.17 , 5.3.0 - 5.3.29 , 7.3.32 - 7.3.33 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/VJfiA on line 18
ArrayPHP_EOLNo match Output for 4.4.5 - 4.4.9 Fatal error: Call to undefined function: str_split() in /in/VJfiA on line 5
Process exited with code 255 . Output for 4.3.2 - 4.3.11 , 4.4.0 - 4.4.4 Fatal error: Call to undefined function: str_split() in /in/VJfiA 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/VJfiA on line 5
preferences:dark mode live preview
221.59 ms | 401 KiB | 325 Q