3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = ( [0] => Array ( [cnt_name] => germany [ent_func] => sec [COUNT(*)] => 31 ) [1] => Array ( [cnt_name] => germany [ent_func] => Coach [COUNT(*)] => 1 ) [2] => Array ( [cnt_name] => germany [ent_func] => officer [COUNT(*)] => 2 ) [3] => Array ( [cnt_name] => france [ent_func] => manager [COUNT(*)] => 3 ) [4] => Array ( [cnt_name] => france [ent_func] => sec [COUNT(*)] => 10 ) ); $countries = array(); $totals = array(); foreach($array AS $subarray) { $countries[$subarray['cnt_name']][$subarray['ent_func']] = $subarray['COUNT(*)']; } print_r($countries);
Output for 5.4.0 - 5.4.22
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in /in/Uf30i on line 4
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected '[' in /in/Uf30i on line 4
Process exited with code 255.