3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $arr = [ 'foo', 'foo', 'bar', 'baZ', 'baz', 'fÖo' ]; $collator = new Collator('en'); $collator->setStrength(Collator::PRIMARY); $arr2 = []; foreach ($arr as $v) { foreach ($arr2 as $v) { if ($collator->compare($v, $v2) === 0) { continue 2; } } $arr2[] = $v; } var_dump($arr2);
based on u7H1I
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.2.6, 7.3.0rc3
Notice: Undefined variable: v2 in /in/9tHYR on line 18 Notice: Undefined variable: v2 in /in/9tHYR on line 18 Notice: Undefined variable: v2 in /in/9tHYR on line 18 Notice: Undefined variable: v2 in /in/9tHYR on line 18 Notice: Undefined variable: v2 in /in/9tHYR on line 18 Notice: Undefined variable: v2 in /in/9tHYR on line 18 Notice: Undefined variable: v2 in /in/9tHYR on line 18 Notice: Undefined variable: v2 in /in/9tHYR on line 18 Notice: Undefined variable: v2 in /in/9tHYR on line 18 Notice: Undefined variable: v2 in /in/9tHYR on line 18 Notice: Undefined variable: v2 in /in/9tHYR on line 18 Notice: Undefined variable: v2 in /in/9tHYR on line 18 Notice: Undefined variable: v2 in /in/9tHYR on line 18 Notice: Undefined variable: v2 in /in/9tHYR on line 18 Notice: Undefined variable: v2 in /in/9tHYR on line 18 array(6) { [0]=> string(3) "foo" [1]=> string(3) "foo" [2]=> string(3) "foo" [3]=> string(3) "foo" [4]=> string(3) "foo" [5]=> string(3) "foo" }
Output for 7.3.0alpha1 - 7.3.0beta1
Fatal error: Uncaught Error: Class 'Collator' not found in /in/9tHYR:12 Stack trace: #0 {main} thrown in /in/9tHYR on line 12
Process exited with code 255.