I'm trying to export matches from preg_match_all to a csv file but am getting the following error:
Warning: fputcsv() expects parameter 2 to be array, string given
This is the section of code I'm having issues with, how can I modify it so I am able to export the matches to a csv file?
preg_match_all($pattern, $pos, $matches);
$fp = fopen('data.csv', 'w');
foreach($matches[0] as $data){
fputcsv($fp,$data);
}
fclose($fp);