/ Published in: PHP
Transforms string to it's possessive form and return it's original case form.
- * Transform text to show ownership e.g Arvi's, Jess'
- public function to_possessive($string)
- $length = strlen($string);
- $last_letter = substr($string, $length-1, $length);
- $letter_s = ctype_upper($string) ? 'S' : 's';
- $possessive_form = ($last_letter == $letter_s) ? $string."'" : $string."'".$letter_s;
- return $possessive_form;
You need to login to post a comment.