Guest User

Untitled

a guest
Apr 4th, 2012
678
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?
  2. // http://bolknote.ru/2012/04/02/~3625
  3. function utf8_strrev_fast($str) {
  4.     $out = '';
  5.  
  6.     for ($l = strlen($str), $i = 0; $i<$l;) {
  7.         $ch = ord($str[$i]);
  8.  
  9.         $len = ($ch & 0b10000000) ?
  10.             ($ch & 0b11110000) == 0b11110000 ? 4 :
  11.             (
  12.                 ($ch & 0b11100000) == 0b11100000 ? 3 : (
  13.                     ($ch & 0b11000000) == 0b11000000 ? 2 : 1
  14.                 )
  15.             ) : 1;
  16.  
  17.         $out = substr($str, $i, $len) . $out;
  18.         $i += $len;
  19.  
  20.     }
  21.     return $out;
  22. }
RAW Paste Data