Last active
May 28, 2023 16:00
-
-
Save joshespi/b693532c531409665cc10fcc27a3e715 to your computer and use it in GitHub Desktop.
Swap abbreviated versions of words/names with PHP
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
function apply_abbreviations($string) { | |
$abbreviated_words = [ | |
"Teaching and Learning" => "T&L", | |
"Teaching & Learning" => "T&L", | |
"Human Resources" => "HR", | |
"Admin" => "Administrator", | |
"Asst" => "Assistant", | |
"Elem" => "Elementary", | |
"Sec" => "Secondary", | |
]; | |
$simplified_string = str_replace(array_keys($abbreviated_words), array_values($abbreviated_words), $string); | |
return $simplified_string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment