3v4l.org

run code in 500+ PHP versions simultaneously
<?php $fake_db_results = [ ['session_id' => 1, 'page_url' => 'http://a.com'], ['session_id' => 1, 'page_url' => 'http://b.com'], ['session_id' => 1, 'page_url' => 'http://c.com'], ['session_id' => 2, 'page_url' => 'http://d.com'], ['session_id' => 2, 'page_url' => 'http://e.com'], ['session_id' => 3, 'page_url' => 'http://f.com'], ['session_id' => 4, 'page_url' => 'http://g.com'], ['session_id' => 5, 'page_url' => 'http://h.com'] ]; $paths = []; foreach ($fake_db_results as $row) { array_push($paths[$row['session_id']], $row['page_url']); }
Output for 8.0.0 - 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: array_push(): Argument #1 ($array) must be of type array, null given in /in/aCsWi:16 Stack trace: #0 /in/aCsWi(16): array_push(NULL, 'http://a.com') #1 {main} thrown in /in/aCsWi on line 16
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: array_push() expects parameter 1 to be array, null given in /in/aCsWi on line 16 Warning: array_push() expects parameter 1 to be array, null given in /in/aCsWi on line 16 Warning: array_push() expects parameter 1 to be array, null given in /in/aCsWi on line 16 Warning: array_push() expects parameter 1 to be array, null given in /in/aCsWi on line 16 Warning: array_push() expects parameter 1 to be array, null given in /in/aCsWi on line 16 Warning: array_push() expects parameter 1 to be array, null given in /in/aCsWi on line 16 Warning: array_push() expects parameter 1 to be array, null given in /in/aCsWi on line 16 Warning: array_push() expects parameter 1 to be array, null given in /in/aCsWi on line 16

preferences:
107.58 ms | 2002 KiB | 4 Q