3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = "id,first_name,last_name,email,country,ip_address 1,Daniel,Jenkins,djenkins0@storify.com,Sweden,234.45.13.29 2,Arthur,Pierce,apierce1@google.cn,Ecuador,83.163.37.204 3,Dorothy,Sanchez,dsanchez2@squarespace.com,Greece,52.251.217.127 4,Anthony,Greene,agreene3@nhs.uk,France,15.123.64.87 5,Catherine,Reyes,creyes4@pinterest.com,Russia,163.2.133.124"; $csv = array_map("str_getcsv", $data); $cols = array_keys($csv[0]); var_dump($csv); var_dump($cols);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, string given in /in/MQ7NU:10 Stack trace: #0 /in/MQ7NU(10): array_map('str_getcsv', 'id,first_name,l...') #1 {main} thrown in /in/MQ7NU on line 10
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: array_map(): Expected parameter 2 to be an array, string given in /in/MQ7NU on line 10 Notice: Trying to access array offset on value of type null in /in/MQ7NU on line 11 Warning: array_keys() expects parameter 1 to be array, null given in /in/MQ7NU on line 11 NULL NULL
Output for 7.3.0 - 7.3.33
Warning: array_map(): Expected parameter 2 to be an array, string given in /in/MQ7NU on line 10 Warning: array_keys() expects parameter 1 to be array, null given in /in/MQ7NU on line 11 NULL NULL
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33
Warning: array_map(): Argument #2 should be an array in /in/MQ7NU on line 10 Warning: array_keys() expects parameter 1 to be array, null given in /in/MQ7NU on line 11 NULL NULL

preferences:
266.6 ms | 403 KiB | 376 Q