Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

split a file at the carriage return

Status
Not open for further replies.

mevasquez

Programmer
Aug 26, 2003
75
US
I have a file with multiple lines and I want to parse it into an array to split the file at each carriage return. I am not sure how to do it. I have used split() in the past; however, I am not sure how to do this for a whole file with multiple lines.

TIA
Mike
 
Thanks, that worked. I have been out of php for about four years. Now I feel like I am re-learning it. There have been some slight changes.

Mike
 
file() as sleipnir214 posts, will split the file into an array using the newline character as the delimiter (but keeping the delimiter at the end of each line).

when you say carriage return do you really mean the CR, or the LF or the combination of the two (CRLF)? if you mean anything other the the LF (alone) then you will need to use a combination of file_get_contents() and explode()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top