I have this code:
PHP Code:
$title = trim($_POST['title']);
$case_changed = ucwords($title);
$case_changed = str_replace("Of", "of", $case_changed);
$case_changed = str_replace("And", "and", $case_changed);
$case_changed = str_replace("For", "for", $case_changed);
$case_changed = str_replace("From", "from", $case_changed);
//Multiple patterns and replacements for entities and greek words
$case_changed = preg_replace($patterns, $replacements, $case_changed);
echo $case_changed;
which is suppose to create Title Case for text entered. How can I run the str_replace on all words after the first because the first word should always be capitalized. I was thinking substr($case_changed, 0, $X) but the first word will never have the same amount of characters.
Thanks for any ideas. (I solved my second question about ucwords and pregreplace after posting and seeing the code some other place).
Bookmarks