Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save CamdenJaxx/5b838d60f814a428b90cdd46255712ef to your computer and use it in GitHub Desktop.

Select an option

Save CamdenJaxx/5b838d60f814a428b90cdd46255712ef to your computer and use it in GitHub Desktop.
Proper Apostrophes In PHP
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