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); 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -