- print_r: documentation ( source)
- preg_match_all: documentation ( source)
<?php
preg_match_all("/(?J)(?:(?P<A>a)!|(?P<A>a)=(?P<type>[si])) (?:(?P<B>b)!|(?P<B>b)=(?P<type>[si]))/", "a! b=s a=i b!", $m, PREG_SET_ORDER);
foreach ($m as $s) {
foreach ($s as $k => $v) {
if (is_int($k)) {
unset($s[$k]);
}
}
print_r($s);
}