3v4l.org

run code in 300+ PHP versions simultaneously
<?php $lines = "name,surname,email John,smith,jsmith@gmail.com HaMish,JONES,ham@seek.com Phil,CARRY,phil@open.edu.au Johnny,O'Hare,john@yahoo.com.au Mike,O'Connor,mo'connor@cat.net.nz WILLIAM,SMYthe,happy@ent.com.au HAMISH,jones,ham@seek.com Sam!!,WalTERS,sam!@walters.org Daley,thompson,daley@yahoo.co.nz kevin,Ruley,kevin.ruley@gmail.com Edward,JIKES,edward@jikes@com.au"; $lines = explode("\n", $lines); $csv = array_map('str_getcsv', $lines); $col_names = array_shift($csv); $users = []; foreach($csv as $row) { $users[] = [ $col_names[0] => ucwords(strtolower($row[0])), // name: $col_names[1] => ucwords(strtolower($row[1])), // surname: $col_names[2] => strtolower($row[2]), // email: ]; } print_r($users);
Output for 8.4.1 - 8.4.14
Deprecated: str_getcsv(): the $escape parameter must be provided as its default value will change in /in/SFYjd on line 17 Deprecated: str_getcsv(): the $escape parameter must be provided as its default value will change in /in/SFYjd on line 17 Deprecated: str_getcsv(): the $escape parameter must be provided as its default value will change in /in/SFYjd on line 17 Deprecated: str_getcsv(): the $escape parameter must be provided as its default value will change in /in/SFYjd on line 17 Deprecated: str_getcsv(): the $escape parameter must be provided as its default value will change in /in/SFYjd on line 17 Deprecated: str_getcsv(): the $escape parameter must be provided as its default value will change in /in/SFYjd on line 17 Deprecated: str_getcsv(): the $escape parameter must be provided as its default value will change in /in/SFYjd on line 17 Deprecated: str_getcsv(): the $escape parameter must be provided as its default value will change in /in/SFYjd on line 17 Deprecated: str_getcsv(): the $escape parameter must be provided as its default value will change in /in/SFYjd on line 17 Deprecated: str_getcsv(): the $escape parameter must be provided as its default value will change in /in/SFYjd on line 17 Deprecated: str_getcsv(): the $escape parameter must be provided as its default value will change in /in/SFYjd on line 17 Deprecated: str_getcsv(): the $escape parameter must be provided as its default value will change in /in/SFYjd on line 17 Array ( [0] => Array ( [name] => John [surname] => Smith [email] => jsmith@gmail.com ) [1] => Array ( [name] => Hamish [surname] => Jones [email] => ham@seek.com ) [2] => Array ( [name] => Phil [surname] => Carry [email] => phil@open.edu.au ) [3] => Array ( [name] => Johnny [surname] => O'hare [email] => john@yahoo.com.au ) [4] => Array ( [name] => Mike [surname] => O'connor [email] => mo'connor@cat.net.nz ) [5] => Array ( [name] => William [surname] => Smythe [email] => happy@ent.com.au ) [6] => Array ( [name] => Hamish [surname] => Jones [email] => ham@seek.com ) [7] => Array ( [name] => Sam!! [surname] => Walters [email] => sam!@walters.org ) [8] => Array ( [name] => Daley [surname] => Thompson [email] => daley@yahoo.co.nz ) [9] => Array ( [name] => Kevin [surname] => Ruley [email] => kevin.ruley@gmail.com ) [10] => Array ( [name] => Edward [surname] => Jikes [email] => edward@jikes@com.au ) )
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27
Array ( [0] => Array ( [name] => John [surname] => Smith [email] => jsmith@gmail.com ) [1] => Array ( [name] => Hamish [surname] => Jones [email] => ham@seek.com ) [2] => Array ( [name] => Phil [surname] => Carry [email] => phil@open.edu.au ) [3] => Array ( [name] => Johnny [surname] => O'hare [email] => john@yahoo.com.au ) [4] => Array ( [name] => Mike [surname] => O'connor [email] => mo'connor@cat.net.nz ) [5] => Array ( [name] => William [surname] => Smythe [email] => happy@ent.com.au ) [6] => Array ( [name] => Hamish [surname] => Jones [email] => ham@seek.com ) [7] => Array ( [name] => Sam!! [surname] => Walters [email] => sam!@walters.org ) [8] => Array ( [name] => Daley [surname] => Thompson [email] => daley@yahoo.co.nz ) [9] => Array ( [name] => Kevin [surname] => Ruley [email] => kevin.ruley@gmail.com ) [10] => Array ( [name] => Edward [surname] => Jikes [email] => edward@jikes@com.au ) )

preferences:
169.99 ms | 417 KiB | 5 Q