retesere20

mb_str_word_count

Nov 28th, 2019
107
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (!function_exists('mb_str_word_count')) {
  2. function mb_str_word_count($string, $format = 0, $charlist = '[]') {
  3. $string=trim($string);
  4. if(empty($string)){$words = array();} else {$words = preg_split('~[^\p{L}\p{N}\']+~u',$string);}
  5. switch ($format) { case 0: return count($words); break; case 1: case 2: return $words; break; default: return $words; break; }
  6. }
  7. }
RAW Paste Data