3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $headers = array( 'one', 'two', 'three', ); $data = array( 'three' => 'someva3', 'one' => 'someval1', 'two' => 'someval2' ); $expected = array( 'someval1', 'someval2', 'someval3' ); $positions = array_flip($headers); $output = array(); foreach($data as $key => $item) { $position = $positions[$key]; $output[$position] = $item; } ksort($output); var_dump($output);
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
array(3) { [0]=> string(8) "someval1" [1]=> string(8) "someval2" [2]=> string(7) "someva3" }
Output for hhvm-3.10.0

Process exited with code 153.