Created
January 26, 2018 13:16
-
-
Save pedroufv/63d69b49089c0421fe4c68414d1e87a7 to your computer and use it in GitHub Desktop.
ignora algumas palavras pro ucfirst como ['de', 'do', 'da', 'e'...]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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