<?php
$sc = 'hello 8491241 some text 6254841 some text 568241 414844:412';
preg_match_all('/([0-9]{5,10})(:[0-9]{1,5})?/', $sc, $matches, PREG_SET_ORDER);
$all_matches = array_reduce($matches, function (array $all, array $match) {
$all[] = ['batch' => $match[1], 'type' => '1'];
if (isset($match[2])) {
$all[] = ['batch' => $match[0], 'type' => '2'];
}
return $all;
}, []);
print_r($all_matches);
preferences:
51.81 ms | 402 KiB | 5 Q