php - Use fputcsv() to insert a row at the top of a csv file? -
pretty simple question. know how use fputcsv()
insert row csv inserts @ bottom. there way use insert @ top of csv?
i need add header existing csv file.
any on great.
thanks!
fputcsv()
inserts data @ file pointer, can rewind() pointer beginning of file.
rewind($handle); fputcsv($handle, $fields);
alternately, can open file pointer @ beginning:
$handle = fopen('yourfile.csv', 'r+'); fputcsv($handle, $fields);