468,101 Members | 1,503 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,101 developers. It's quick & easy.

Remove last row from csv file using PHP

Is it possible to remove the last row of the downloaded csv file, and the removed row will gets added in next sheet. May I know is this possible in PHP. As I searched in google and I didnt find any solutions.
Jun 14 '19 #1
1 1302
5,390 Expert Mod 4TB
what exactly do you mean with 'next sheet' - removing a line from a file is relatively easy and could be done in different ways - personally i would probably use the file-method so i would have the lines in an array already. now you can do with it whatever you want - like deleting the original file and write all except the last line back to a file and then put the last line wherever you want to.

PS: note - it will split the lines at newline characters - so if the values in a csv line contain such then it might be necessary to use another method like fgetcsv or such.
Jun 14 '19 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Venkat | last post: by
2 posts views Thread by Paul LAURENT | last post: by
3 posts views Thread by syntax | last post: by
8 posts views Thread by =?Utf-8?B?Q2hyaXMgRmluaw==?= | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.