3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "abbacbzcz"; $array = str_split($string); $array = array_count_values($array); $array = array_filter($array, function($val) { return $val == 1;}); $first_non_repeated_letter = key(array_shift($array)); var_export($first_non_repeated_letter);
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Fatal error: Uncaught TypeError: key(): Argument #1 ($array) must be of type array, null given in /in/aM73X:8 Stack trace: #0 /in/aM73X(8): key(NULL) #1 {main} thrown in /in/aM73X on line 8
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: key() expects parameter 1 to be array, null given in /in/aM73X on line 8 NULL

preferences:
92.09 ms | 1275 KiB | 4 Q