3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function my_array_diff($a, $b) { $map = $out = array(); foreach($a as $val) $map[$val] = 1; foreach($b as $val) if(isset($map[$val])) $map[$val] = 0; foreach($map as $val => $ok) if($ok) $out[] = $val; return $out; } $a=array('a','A','b'); $b=array('A','c','b'); $t1=time(); print_r(my_array_diff($a,$b)); $t2=time()-$t1; echo $t2; $t1=time(); print_r(array_diff($a,$b)); $t2=time()-$t1; echo $t2;
based on usv79
Output for 4.3.0 - 7.2.0
Array ( [0] => a ) 0Array ( [0] => a ) 0