Chris Muench Chris Muench - 1 year ago 104
PHP Question

explode textarea php (at new lines)

can I do:

explode("\n", $_POST['thetextarea']);

and have it work on all platforms? (The question I am asking is will it ever be \r\n and not just \n")


I forgot to mention that I am saving $_POST['thetextarea'] to a mysql database VARCHAR 255. It seems \r\n is converted to \n.

Answer Source

This will do the trick given \r\n, \r or \n:

preg_split('/\r\n|[\r\n]/', $_POST['thetextarea'])
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download