Created
July 23, 2020 21:46
-
-
Save CamdenJaxx/5b838d60f814a428b90cdd46255712ef to your computer and use it in GitHub Desktop.
Proper Apostrophes In PHP
This file contains hidden or 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 properize($string) { | |
| return $string.'\''.($string[strlen($string) - 1] != 's' ? 's' : ''); | |
| } | |
| echo 'Properize: '.properize("Chris"); //returns Chris' | |
| echo 'Properize: '.properize("David"); //returns David's | |
| // Source: https://davidwalsh.name/php-possessive-punctuation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment