I have a .txt file with content(see first image) I need the content in such a way that It should be numbered and comma at the end of every line(see second image).


- I want to insert say: “1”=>” in front of the first line. The numbering will increase on the second line so having about 4747 lines the last number will be 4747.
- then insert: “, at the end of every line.
I have some knowlege in PHP so if somebody has solution or idea that will be helpful. I have been formatting this manually and that is very time consuming
Use PHP’s file(), which will give you an array with one element for each line. After that it should be a simple matter of iterating over the array with
foreachand concatenating the appropriate bits onto the string. Then usefopen()andfwrite()to write the edited lines to your output file.