3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $subset = [1,2,3]; $array = [2,1,5]; var_dump(array_intersect($subset, $array)); $patched = array_intersect($array, $subset); sort($patched); sort($subset); var_dump($array); var_dump($subset); var_dump($patched);
Output for 7.2.0
array(2) { [0]=> int(1) [1]=> int(2) } array(3) { [0]=> int(2) [1]=> int(1) [2]=> int(5) } array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } array(2) { [0]=> int(1) [1]=> int(2) }