Guest User

Untitled

a guest
Dec 17th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1.         public function parse_message($str) {
  2.             $arguments = explode(' ', $str);
  3.             $count = count($arguments);
  4.             $username = explode('!', substr($arguments[0], 1));
  5.             $username = isset($username[0]) ? $username[0] : '';
  6.             $command = isset($arguments[1]) ? $arguments[1] : '';
  7.             $args = "";
  8.             for($i = 2; $i < $count; $i++)
  9.                 $args .= $arguments[$i] . ' ';
  10.             $trailing_data = stripos($str, ' :');
  11.             $trailing_data = trim(substr($str, $trailing_data + 2));
  12.             $trailing_data_pos = stripos($args, ' :');
  13.             $args = trim(substr($args, 0, $trailing_data_pos));
  14.            
  15.             return array('username' => $username, 'command' => $command, 'trail' => $trailing_data, 'args' => $args);
  16.         }
Add Comment
Please, Sign In to add comment