I'm trying something like this -
$foo = "foo555bar25foobar1";
if(1 === preg_match('~[0-9]~', $foo, $matches) {
$bar = preg_replace($matches, "-".$matches."-", $foo);
};
echo $bar;
The result I'm looking to achieve is: foo-555-bar-25-foobar-1-
$foo = "foo555bar25foobar1";
$bar = preg_replace('/\d+/', '-$0-', $foo);
echo $bar;