Guest User

Untitled

a guest
Dec 5th, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. function react_str_replace(string $units, ?string $exclude = null): int
  2. {
  3.     if($exclude)
  4.     {
  5.         $units = str_replace(array($exclude, strtoupper($exclude)), '', $units);
  6.     }
  7.  
  8.     $len = strlen($units);
  9.     $i = 0;
  10.  
  11.     while($i<$len-1)
  12.     {
  13.         $diff = ord($units[$i]) - ord($units[$i+1]);
  14.  
  15.         if((($diff ^ ($diff >> 31)) - ($diff >> 31)) === 32)
  16.         {
  17.             $units = substr($units, 0, $i) . substr($units, $i+2);
  18.             if($i) $i--;
  19.             $len -= 2;
  20.         } else {
  21.             $i++;
  22.         }
  23.     }
  24.  
  25.     return $len;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment