- var_dump: documentation ( source)
- preg_match: documentation ( source)
- str_replace: documentation ( source)
- str_split: documentation ( source)
<?php
$input = 'S1G5AB'; // given this
$store = '5I6GAB'; // actually this
$chars = str_split($input);
var_dump($chars);
$regex = str_replace(['S','5','G','6','1','I'], ['[S5]','[S5]','[G6]','[G6]','[I1]','[I1]'], $input);
echo $regex;
echo (0 < preg_match("/$regex/", $store) ? 'Match' : 'No match');