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

Php - Delimiter must not be alphanumeric or backslash -

c# - How to change the "Applies To" field under folder auditing options programatically (.NET) -

c++ - Ambiguity when using boost::assign::list_of to construct a std::vector -