A 'match_all' helper function based on dulao's answer. Someone might find it useful...
<?php
function mb_ereg_match_all($pattern, $subject, &$matches, $options = '', $setOrder = false, $offset = 0) {
if (!mb_ereg_search_init($subject, $pattern, $options)) {
return false;
}
if ($offset != 0 && !mb_ereg_search_setpos($offset)) {
return false;
}
$matches = [];
if (!mb_ereg_search()) {
return 0;
}
$regs = mb_ereg_search_getregs();
$count = 0;
do {
$count++;
if ($setOrder) {
foreach ($regs as $key => $val) {
$matches[$key][] = $val;
}
} else {
$matches[] = $regs;
}
$regs = mb_ereg_search_regs();
}
while($regs);
return $count;
}
?>