3v4l.org

run code in 300+ PHP versions simultaneously
<?php $messageRow = [ 'event_id' => 123, 'event_status' => 50, ]; if (array_key_exists('event_id', $messageRow) && array_key_exists('event_status', $messageRow)) { $id = [ 'event_id' => $messageRow['event_id'], 'event_status' => $messageRow['event_status'], ]; var_dump('A'); } elseif (array_key_exists('event_id', $messageRow)) { $id = $messageRow['event_id']; var_dump('B'); } var_dump($id); echo str_repeat(PHP_EOL, 3) . str_repeat('-', 100) . PHP_EOL; $messageRow = [ 'event_id' => 123, 'event_status' => 50, ]; if (array_key_exists('event_id', $messageRow)) { $id = $messageRow['event_id']; var_dump('C'); } elseif (array_key_exists('event_id', $messageRow) && array_key_exists('event_status', $messageRow)) { $id = [ 'event_id' => $messageRow['event_id'], 'event_status' => $messageRow['event_status'], ]; var_dump('D'); } var_dump($id); echo str_repeat(PHP_EOL, 3) . str_repeat('-', 100) . PHP_EOL; $messageRow = [ 'event_id' => 123, 'event_status' => 50, ]; if (array_key_exists('event_id', $messageRow)) { $id = $messageRow['event_id']; var_dump('E'); } if (array_key_exists('event_id', $messageRow) && array_key_exists('event_status', $messageRow)) { $id = [ 'event_id' => $messageRow['event_id'], 'event_status' => $messageRow['event_status'], ]; var_dump('F'); } var_dump($id);
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
string(1) "A" array(2) { ["event_id"]=> int(123) ["event_status"]=> int(50) } ---------------------------------------------------------------------------------------------------- string(1) "C" int(123) ---------------------------------------------------------------------------------------------------- string(1) "E" string(1) "F" array(2) { ["event_id"]=> int(123) ["event_status"]=> int(50) }
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/2pkil on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/2pkil on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/2pkil on line 4
Process exited with code 255.

preferences:
234.67 ms | 402 KiB | 354 Q