Skip to content

Instantly share code, notes, and snippets.

@pedroufv
Created January 26, 2018 13:16
Show Gist options
  • Save pedroufv/63d69b49089c0421fe4c68414d1e87a7 to your computer and use it in GitHub Desktop.
Save pedroufv/63d69b49089c0421fe4c68414d1e87a7 to your computer and use it in GitHub Desktop.
ignora algumas palavras pro ucfirst como ['de', 'do', 'da', 'e'...]
<?php
function titleCase($str, $ignored = []) {
$words = explode(' ', $str);
foreach ($words as &$word) {
if (in_array($word, $ignored) {
continue;
}
$word = ucfirst($word);
}
return implode(' ', $words);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment