Guest User

Untitled

a guest
Oct 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Checks for the length of a string, mb strings accounted for
  5. *
  6. * @param string The string to check the length of.
  7. * @return int The length of the string.
  8. */
  9. function my_strlen($string)
  10. {
  11. global $lang;
  12.  
  13. $string = preg_replace("#&\#([0-9]+);#", "-", $string);
  14.  
  15. if(strtolower($lang->settings['charset']) == "utf-8")
  16. {
  17. // Get rid of any excess RTL and LTR override for they are the workings of the devil
  18. $string = str_replace(dec_to_utf8(8238), "", $string);
  19. $string = str_replace(dec_to_utf8(8237), "", $string);
  20.  
  21. // Remove dodgy whitespaces
  22. $string = str_replace(chr(0xCA), "", $string);
  23. }
  24. $string = trim($string);
  25.  
  26. if(function_exists("mb_strlen"))
  27. {
  28. $string_length = mb_strlen($string);
  29. }
  30. else
  31. {
  32. $string_length = strlen($string);
  33. }
  34.  
  35. return $string_length;
  36. }
Add Comment
Please, Sign In to add comment