3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array_to_reorder = array('home', 'school', 'phone', 'name', '...', '..'); $shorting = array('name', 'phone', 'home'); var_dump(array_merge($shorting, array_diff($array_to_reorder, $shorting)));
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(6) { [0]=> string(4) "name" [1]=> string(5) "phone" [2]=> string(4) "home" [3]=> string(6) "school" [4]=> string(3) "..." [5]=> string(2) ".." }