3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $messages = [ 'Fout in veld 1', 'Fout in veld 2', 'Fouten in veld 3' => [ 'titel', 'is niet uniek', 'moet minimaal 3 tekens lang zijn', ], 'Fout in veld 6' ]; function rec($messages, $i = 0) { foreach($messages as $title => $message) { if (is_array($message)) { $k = $i + 1; return rec($message, $k); } $output = ''; for ($j = -1; $j < $i; $j++) { $output .= ' - '; } echo $output . $message + "\n"; } } rec($messages);
based on NmoM1
Output for 7.1.0 - 7.2.0
Warning: A non-numeric value encountered in /in/vOv2h on line 31 Warning: A non-numeric value encountered in /in/vOv2h on line 31 0 Warning: A non-numeric value encountered in /in/vOv2h on line 31 Warning: A non-numeric value encountered in /in/vOv2h on line 31 0 Warning: A non-numeric value encountered in /in/vOv2h on line 31 Warning: A non-numeric value encountered in /in/vOv2h on line 31 0 Warning: A non-numeric value encountered in /in/vOv2h on line 31 Warning: A non-numeric value encountered in /in/vOv2h on line 31 0 Warning: A non-numeric value encountered in /in/vOv2h on line 31 Warning: A non-numeric value encountered in /in/vOv2h on line 31 0
Output for 5.4.1 - 7.0.20
00000
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/vOv2h on line 3
Process exited with code 255.