3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $arr = [ 'foo', 'foo', 'bar', 'baz', 'baz' ]; array_walk($arr, function ($item, $k) use ($arr) { $lower = mb_strtolower($item, 'utf-8'); foreach ($arr as $i => $v) { var_dump($k .'='. $i); if ($i !== $k && $v !== null && $lower === mb_strtolower($v, 'utf-8')) { var_dump('rm'); unset($arr[$i]); } } }); var_dump($arr);
based on 8piMk
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0rc3
string(3) "0=0" string(3) "0=1" string(2) "rm" string(3) "0=2" string(3) "0=3" string(3) "0=4" string(3) "1=0" string(2) "rm" string(3) "1=1" string(3) "1=2" string(3) "1=3" string(3) "1=4" string(3) "2=0" string(3) "2=1" string(3) "2=2" string(3) "2=3" string(3) "2=4" string(3) "3=0" string(3) "3=1" string(3) "3=2" string(3) "3=3" string(3) "3=4" string(2) "rm" string(3) "4=0" string(3) "4=1" string(3) "4=2" string(3) "4=3" string(2) "rm" string(3) "4=4" array(5) { [0]=> string(3) "foo" [1]=> string(3) "foo" [2]=> string(3) "bar" [3]=> string(3) "baz" [4]=> string(3) "baz" }