I\'m new at PHP and keep struggling to read a CSV file into a 2D-array. I use the following file \'csv/team.csv\':
ID,Nickname,Shirtnumber,Position 1,Jimmy,0
I think str_getcsv comment contains very laconic solution, although it can be improved by using array_walk $userdata parameter:
$userdata
array_walk($teamdata, function(&$player, $_, $headers) { $player = array_combine($headers, $player); }, array_shift($teamdata));
Here is the demo.