line endingg

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

line endingg

Post by magicrobotmonkey »

The specs for a project I'm working on require that I take new-line delimited information from a text box and put it into an array. I am having trouble trying to figure the best way to do this so that I can take input from macs, windows boxes, or linux boxes. Right now I just explode on "\r\n\" and that works fine, but I know its not going to work for a mac or for a linux machine. Has anyone run into this problem before? I am just trying to figure out a couple of str_replaces or something in the right order which will ensure that I get similar output from \r\n, \r, or \n.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

$arr = preg_split('#ї\r\n]+#', $yourText);
:)
Post Reply