3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array('a' => $a, 'b' => $b, 'c' =>$c); foreach($array as $letter => $subArray){ foreach($subArray as $key => $values){ $newArray[$letter.$key] = $values['value']; } } $uniques = array_unique($newArray); //getting the non-repeated values $repeated = array_diff_assoc($newArray, $uniques); // stripping them out $final = array_unique($repeated); //cleaning the repeated values to just 1 of each print_r($final);
Output for 5.3.0 - 7.1.0
Notice: Undefined variable: a in /in/crVJ7 on line 2 Notice: Undefined variable: b in /in/crVJ7 on line 2 Notice: Undefined variable: c in /in/crVJ7 on line 2 Warning: Invalid argument supplied for foreach() in /in/crVJ7 on line 4 Warning: Invalid argument supplied for foreach() in /in/crVJ7 on line 4 Warning: Invalid argument supplied for foreach() in /in/crVJ7 on line 4 Notice: Undefined variable: newArray in /in/crVJ7 on line 9 Warning: array_unique() expects parameter 1 to be array, null given in /in/crVJ7 on line 9 Notice: Undefined variable: newArray in /in/crVJ7 on line 10 Warning: array_diff_assoc(): Argument #1 is not an array in /in/crVJ7 on line 10 Warning: array_unique() expects parameter 1 to be array, null given in /in/crVJ7 on line 11
Output for 5.0.4 - 5.2.17
Notice: Undefined variable: a in /in/crVJ7 on line 2 Notice: Undefined variable: b in /in/crVJ7 on line 2 Notice: Undefined variable: c in /in/crVJ7 on line 2 Warning: Invalid argument supplied for foreach() in /in/crVJ7 on line 4 Warning: Invalid argument supplied for foreach() in /in/crVJ7 on line 4 Warning: Invalid argument supplied for foreach() in /in/crVJ7 on line 4 Notice: Undefined variable: newArray in /in/crVJ7 on line 9 Warning: array_unique(): The argument should be an array in /in/crVJ7 on line 9 Notice: Undefined variable: newArray in /in/crVJ7 on line 10 Warning: array_diff_assoc(): Argument #1 is not an array in /in/crVJ7 on line 10 Warning: array_unique(): The argument should be an array in /in/crVJ7 on line 11
Output for 4.3.2 - 4.3.10, 4.4.0 - 5.0.3
Notice: Undefined variable: a in /in/crVJ7 on line 2 Notice: Undefined variable: b in /in/crVJ7 on line 2 Notice: Undefined variable: c in /in/crVJ7 on line 2 Warning: Invalid argument supplied for foreach() in /in/crVJ7 on line 4 Warning: Invalid argument supplied for foreach() in /in/crVJ7 on line 4 Warning: Invalid argument supplied for foreach() in /in/crVJ7 on line 4 Notice: Undefined variable: newArray in /in/crVJ7 on line 9 Warning: array_unique(): The argument should be an array in /in/crVJ7 on line 9 Notice: Undefined variable: newArray in /in/crVJ7 on line 10 Warning: array_diff_assoc(): Argument #1 is not an array in /in/crVJ7 on line 10 Warning: array_unique(): The argument should be an array in /in/crVJ7 on line 11
Output for 4.3.11
Notice: Undefined variable: a in /in/crVJ7 on line 2 Notice: Undefined variable: b in /in/crVJ7 on line 2 Notice: Undefined variable: c in /in/crVJ7 on line 2 Notice: Undefined variable: newArray in /in/crVJ7 on line 9 Warning: array_unique(): The argument should be an array in /in/crVJ7 on line 9 Notice: Undefined variable: newArray in /in/crVJ7 on line 10 Warning: array_diff_assoc(): Argument #1 is not an array in /in/crVJ7 on line 10 Warning: array_unique(): The argument should be an array in /in/crVJ7 on line 11
Output for 4.3.0 - 4.3.1
Notice: Undefined variable: a in /in/crVJ7 on line 2 Notice: Undefined variable: b in /in/crVJ7 on line 2 Notice: Undefined variable: c in /in/crVJ7 on line 2 Warning: Invalid argument supplied for foreach() in /in/crVJ7 on line 4 Warning: Invalid argument supplied for foreach() in /in/crVJ7 on line 4 Warning: Invalid argument supplied for foreach() in /in/crVJ7 on line 4 Notice: Undefined variable: newArray in /in/crVJ7 on line 9 Warning: array_unique() [http://www.php.net/function.array-unique]: The argument should be an array in /in/crVJ7 on line 9 Notice: Undefined variable: newArray in /in/crVJ7 on line 10 Warning: array_diff_assoc() [http://www.php.net/function.array-diff-assoc]: Argument #1 is not an array in /in/crVJ7 on line 10 Warning: array_unique() [http://www.php.net/function.array-unique]: The argument should be an array in /in/crVJ7 on line 11