- var_dump: documentation ( source)
<?php
function array_greedy_diff($x, $y) {
$output = $x;
for($i = $j = 0; $i < count($x) && j < count($y); ) {
if ($x[i] == $y[j]) {
unset($output[i]);
$x++;
}
$j++;
}
return $output;
}
$a = array(1,2,3,1,2,3);
$b = array(1,2,3);
var_dump(array_greedy_diff($a, $b));