3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ '7.2' => 1, '72' => 2]; foreach( $array as $k => $v) { print $k[0].PHP_EOL; }
Output for 8.3.0 - 8.3.4
7 Warning: Trying to access array offset on int in /in/m9O3c on line 5
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17
7 Warning: Trying to access array offset on value of type int in /in/m9O3c on line 5
Output for 7.4.0 - 7.4.33
7 Notice: Trying to access array offset on value of type int in /in/m9O3c on line 5
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
7

preferences:
174.37 ms | 402 KiB | 168 Q