- preg_replace: documentation ( source)
- rand: documentation ( source)
<?php
class My{
function prepare($text){
return preg_replace(
'/\{(.+?)\}/',
'\1',
$text
);
}
private function rand(array $values){
return $values[rand(0, sizeof($values)-1)];
}
}
echo (new My)->prepare('i choose {ps3|games}');