here is a better and possibly faster version that i just found out myself, that supports utf-8 multibyte characters.
in my experience regex functions are slow in php, so here is a string manipulation based function.
function replace_first_word($text,$format='<big>{L}</big>'){
//*** UTF-8 replace first letter of every word ***
//split words
$words = explode(' ', $text);
//pick up each word
foreach($words as &$word){
//find out first letter of word
$first = substr($word, 0,1);
//remove first letter from word
$word = substr($word,1);
//replace first letter with formatted letter
$first = str_replace('{L}',$first,$format);
//add replaced letter to word
$word = $first.$word;
}
//glue words back together and return them
return implode(' ',$words);
}
also before php6 comes out, remember to set these 2 variables in php.ini to better support utf-8
mbstring.func_overload "7"
mbstring.internal_encoding "UTF-8"