Verander u benadering 'n bietjie. In plaas daarvan om die soekterm en skeier in 'n enkele string te stoor, gebruik twee veranderlikes.
$sep = '--->';
$searchfor = '124';
$pattern = "/^$sep\s+($searchfor\d+)\s+.*/m";
// search, and store all matching occurences in $matches
if(preg_match_all($pattern, $contents, $matches)){
echo implode(' ', $matches[1])."\n";
}
Uitsette:
12455 12477