3v4l.org

run code in 300+ PHP versions simultaneously
<?php class My{ function prepare($text){ return preg_replace( '/\{(.+?)\}/', $this->rand(explode('|', '\\1')), $text ); } private function rand(array $values){ return $values[rand(0, sizeof($values)-1)]; } } echo (new My)->prepare('i choose {ps3|games}');

preferences:
30.69 ms | 402 KiB | 5 Q