$text = '10,15,20,25,30,22,14,33';
$sets = array_map(function ($values) {
return sprintf('/(%s)/', implode('|', $values));
}, [
range(10, 15),
range(20, 25),
range(30, 35),
]);
$output = preg_replace($sets, [
'Alface', 'Beringela', 'Couve',
], $text);
echo $output;
Created
November 5, 2016 19:39
-
-
Save flyingluscas/56917c84ac61b8ff5457f7a3d69157ab to your computer and use it in GitHub Desktop.
Example
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment