Sha256: 2cf72a0e9e564fa49407a52bda919c24a95fe649612b88b29d68d017418661d6
Contents?: true
Size: 401 Bytes
Versions: 393
Compression:
Stored size: 401 Bytes
Contents
<?php /** * Abbreviates a phrase. * * @param string $phrase * @return string */ function acronym($phrase) { $matches = preg_match_all('/\p{Lu}+\p{Ll}*|\p{Ll}+/u', $phrase, $words); if ($matches === false || $matches < 2) { return ''; } return array_reduce($words[0], function ($acronym, $word) { return $acronym.mb_strtoupper(mb_substr($word, 0, 1)); }); }
Version data entries
393 entries across 393 versions & 1 rubygems