Sunday, March 26, 2023

parsing a csv with pipe symbol as separator in PHP

Following this discussion, where it was noted that "PHP's array_map() supports a third parameter which is an array representing the parameters to pass to the callback function" the method I used was:

$file = "../path/to/".$playlistDatenodash.".csv";
$filearray = file($file);
$data = array_map('str_getcsv', $filearray, array_fill(0,count($filearray),'|'));


No comments:

Post a Comment