3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $sentence = '{Please|Just} make this {cool|awesome|random} test sentence {rotate {quickly|fast} and random|spin and be random}'; function sentence_spinning($str) { $new_str = preg_replace_callback('#\{([^{}]*)\}#im', function($matches) { $rand = array_rand($split = explode('|', $matches[1])); return $split[$rand]; }, $str); return ($new_str !== $str) ? sentence_spinning($new_str) ? $str; if ($new_str !== $str) $str = sentence_spinning($new_str); return $str; } echo sentence_spinning($sentence);
Output for 5.3.0 - 5.4.21
Parse error: syntax error, unexpected ';' in /in/ve4PP on line 13
Process exited with code 255.