3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array( array( "type" => "a", "value" => 1 ), array( "type" => "a", "value" => 2 ), array( "type" => "a", "value" => 3 ), array( "type" => "b", "value" => 1 ), array( "type" => "b", "value" => 2 ),array( "type" => "b", "value" => 4 ), array( "type" => "f", "value" => 2 ) ); foreach ($array as $element) $newArray[$element["type"]][] = $element["value"]; var_export($newArray);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array ( 'a' => array ( 0 => 1, 1 => 2, 2 => 3, ), 'b' => array ( 0 => 1, 1 => 2, 2 => 4, ), 'f' => array ( 0 => 2, ), )