- var_dump: documentation ( source)
- array_intersect: documentation ( source)
- sort: documentation ( source)
<?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);