3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = [ [ "id" => 1, "controller" => "users", "action" => "index" ], [ "id" => 1, "controllers" => "users", "action" => "" ], [ "id" => 1, "controller" => "users", "action" => "login" ] ]; $b = [ [ "id" => 1, "controller" => "users", "action" => "index" ], [ "id" => 1, "controllers" => "users", "action" => "" ], [ "id" => 1, "controller" => "users", "action" => "logout" ] ]; $final = array(); foreach($a AS $item) { $final[$item['controller'] . $item['action']] = $item; } foreach($b AS $item) { unset($final[$item['controller'] . $item['action']]); } $final = array_values($final); print_r($final); print_r($final);
based on SLlkE
Output for 5.4.0 - 7.2.0
Notice: Undefined index: controller in /in/XgCpH on line 42 Notice: Undefined index: controller in /in/XgCpH on line 46 Array ( [0] => Array ( [id] => 1 [controller] => users [action] => login ) ) Array ( [0] => Array ( [id] => 1 [controller] => users [action] => login ) )
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/XgCpH on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/XgCpH on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/XgCpH on line 3
Process exited with code 255.