Please use the below function to get the sentence/string initial (abbreviation).
Also, please use the link to understand more about regular expression using this Regular Expression Tutorials
function initials($str) { $matches = preg_split("/[,]/", $str); $initials = array(); foreach ($matches as $list) { $words = preg_split("/[^\w-]/", ($list)); $initial = ''; foreach ($words as $word) { $initial .= strtoupper($word[0]); } $initials[] = $initial; } return ( implode('/', $initials) ); }
Also, please use the link to understand more about regular expression using this Regular Expression Tutorials
No comments:
Post a Comment
Please post any queries and comments here.