Hi,
I have set up a simple function so that when a user enters a title in a php form, php gives the first letter of each word a capital letter. As follows:
function caps($text){
$search_text=$text;
$search_text=ucwords(strtolower($search_text));
$look_for = "(a";
$change_to = "(A";
$changed_text = str_replace($look_for, $change_to, $search_text);
$search_text=$changed_text;
$look_for = "(b";
$change_to = "(B";
$changed_text = str_replace($look_for, $change_to, $search_text);
$search_text=$changed_text;
$look_for = "(c";
$change_to = "(C";
//...etc...etc.. up to
$look_for = "(z";
$change_to = "(Z";
$changed_text = str_replace($look_for, $change_to, $search_text);
$search_text=$changed_text;
return $search_text;
}
The trouble is, if I were to enter the following "The secret of DNA", my function would return "The Secret Of Dna" (removes the caps). Any ideas how to get around this would be most useful. Thanks in advance.
Russ