3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $data = array( array('id' => 1, 'field' => 13, 'value' => 'foo'), array('id' => 3, 'field' => 13, 'value' => 'bar'), array('id' => 4, 'field' => 13, 'value' => 'baz'), array('id' => 2, 'field' => 13, 'value' => 'foo'), array('id' => 1, 'field' => 17, 'value' => 'bar'), array('id' => 2, 'field' => 17, 'value' => 'baz'), ); $result = array(); foreach ($data as $row) { $result[$row['id']][$row['field']] = $row['value']; } ksort($result); var_dump($result);
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
array(4) { [1]=> array(2) { [13]=> string(3) "foo" [17]=> string(3) "bar" } [2]=> array(2) { [13]=> string(3) "foo" [17]=> string(3) "baz" } [3]=> array(1) { [13]=> string(3) "bar" } [4]=> array(1) { [13]=> string(3) "baz" } }
Output for hhvm-3.10.0

Process exited with code 153.