- preg_replace: documentation ( source)
<?php
$text = 'PHP Tutorial';
$text = preg_replace('/(\b[a-z])/i','<span style="color:red;">\1</span>',$text);
echo $text;
?>
- See more at: http://www.w3resource.com/php-exercises/php-basic-exercises.php#EDITOR