- print_r: documentation ( source)
- ucwords: documentation ( source)
- preg_replace: documentation ( source)
<?php
$string = 'foobar, 2 foo 3 bar';
$string = preg_replace("/\s| /",' ', $string);
$output = ucwords($string);
print_r($output);