Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
$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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.