3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $original_ids = array(1, 2, 3, 4); //<--- Original values without sorted. $sorted_ids = array(4, 1, 3); //<--- Fixed values (sort by this) $result_ids = array(); //<--- The result array after sorted $result_ids = array_intersect($original_ids, $sorted_ids); var_dump($result_ids);
Output for 4.3.0 - 7.1.0
array(3) { [0]=> int(1) [2]=> int(3) [3]=> int(4) }