3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $str = 'chat @julio "salut à toi" hey "1 2 3"'; $str = '<?php ' . str_replace( '@', '*', $str ); $a=token_get_all($str); array_shift( $a ); $a = array_column( $a, 1 ); $a = array_map( 'trim', $a ); $a = array_filter( $a ); $a = array_values( $a ); //list( $subcommand, $user, $args ) = $input = array("red", "green", "blue", "yellow"); var_dump($a); var_dump( $input ); array_splice($input, 2); var_dump( $input ); var_dump( array_splice( $a, 2 ) ); var_dump($subcommand); var_dump($user); var_dump($args);
Output for 5.6.30
array(5) { [0]=> string(4) "chat" [1]=> string(5) "julio" [2]=> string(14) ""salut à toi"" [3]=> string(3) "hey" [4]=> string(7) ""1 2 3"" } array(4) { [0]=> string(3) "red" [1]=> string(5) "green" [2]=> string(4) "blue" [3]=> string(6) "yellow" } array(2) { [0]=> string(3) "red" [1]=> string(5) "green" } array(3) { [0]=> string(14) ""salut à toi"" [1]=> string(3) "hey" [2]=> string(7) ""1 2 3"" } Notice: Undefined variable: subcommand in /in/VcmZR on line 18 NULL Notice: Undefined variable: user in /in/VcmZR on line 19 NULL Notice: Undefined variable: args in /in/VcmZR on line 20 NULL