3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'foobar, 2&nbsp;foo 3&nbsp;bar'; $string = preg_replace("/\s|&nbsp;/",' ', $string); $output = ucwords($string); print_r($output);

preferences:
29.84 ms | 1525 KiB | 5 Q