Search code examples
htmlphp-5.3

How to read an HTML page line by line using php?


How to read an HTML page line by line using php. I have to add and edit some file paths of my html page using php.


Solution

  • Unless you explicitly want to read a HTML file line by line, use a DOM parser.

    Otherwise, if for some reason you do want to read it line by line, split the contents by newline \n (should be, you may want to normalise other newline types like \r\n) and then iterate through the resulting array.