Here is my codes:
$sc = 'hello 8491241 some text 6254841 some text 568241 414844:412';
preg_match_all('/[0-9]{5,10}/', $sc, $matches1);
preg_match_all('/[0-9]{5,10}:[0-9]{1,5}/', $sc, $matches2);
function cub1($match)
{
return array(
'batch' => $match,
'type' => '1',
);
}
function cub2($match)
{
return array(
'batch' => $match,
'type' => '2',
);
}
$pr_matches1 = array_map('cub1', $matches1[0]);
$pr_matches2 = array_map('cub2', $matches2[0]);
$all_matches = array_merge($pr_matches1,$pr_matches2);
It just works fine, i'm asking about if it possible to improve my codes and make the array_map callback functions (cub1 and cub2) as one function (cub), i just need to set different 'types' for $matches1 and $matches2
Any idea please?