3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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", str_getcsv($data)); $cols = array_shift($csv); var_dump($csv); var_dump($cols);
based on MQ7NU
Output for 5.3.0 - 7.3.0beta1
array(30) { [0]=> array(1) { [0]=> string(10) "first_name" } [1]=> array(1) { [0]=> string(9) "last_name" } [2]=> array(1) { [0]=> string(5) "email" } [3]=> array(1) { [0]=> string(7) "country" } [4]=> array(1) { [0]=> string(12) "ip_address 1" } [5]=> array(1) { [0]=> string(6) "Daniel" } [6]=> array(1) { [0]=> string(7) "Jenkins" } [7]=> array(1) { [0]=> string(21) "djenkins0@storify.com" } [8]=> array(1) { [0]=> string(6) "Sweden" } [9]=> array(1) { [0]=> string(14) "234.45.13.29 2" } [10]=> array(1) { [0]=> string(6) "Arthur" } [11]=> array(1) { [0]=> string(6) "Pierce" } [12]=> array(1) { [0]=> string(18) "apierce1@google.cn" } [13]=> array(1) { [0]=> string(7) "Ecuador" } [14]=> array(1) { [0]=> string(15) "83.163.37.204 3" } [15]=> array(1) { [0]=> string(7) "Dorothy" } [16]=> array(1) { [0]=> string(7) "Sanchez" } [17]=> array(1) { [0]=> string(25) "dsanchez2@squarespace.com" } [18]=> array(1) { [0]=> string(6) "Greece" } [19]=> array(1) { [0]=> string(16) "52.251.217.127 4" } [20]=> array(1) { [0]=> string(7) "Anthony" } [21]=> array(1) { [0]=> string(6) "Greene" } [22]=> array(1) { [0]=> string(15) "agreene3@nhs.uk" } [23]=> array(1) { [0]=> string(6) "France" } [24]=> array(1) { [0]=> string(14) "15.123.64.87 5" } [25]=> array(1) { [0]=> string(9) "Catherine" } [26]=> array(1) { [0]=> string(5) "Reyes" } [27]=> array(1) { [0]=> string(21) "creyes4@pinterest.com" } [28]=> array(1) { [0]=> string(6) "Russia" } [29]=> array(1) { [0]=> string(13) "163.2.133.124" } } array(1) { [0]=> string(2) "id" }
Output for 5.0.0 - 5.2.17
Fatal error: Call to undefined function str_getcsv() in /in/YlIOd on line 10
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: str_getcsv() in /in/YlIOd on line 10
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: str_getcsv() in /in/YlIOd on line 10
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: str_getcsv() in /in/YlIOd on line 10