Parsing Input for my Database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Death
Forum Newbie
Posts: 17
Joined: Tue Apr 19, 2005 11:52 am

Parsing Input for my Database

Post by Death »

Hi guys,

Basically I want to put something like the following in a <TEXTAREA> and then add it to my database:

101|555|some text
130|666|more text

...that would be two rows. In this example I chose the bar (|) as the delimiter. Do I parse it myself ? What about the line feeds, do I need to worry about the \r\n vs. \n for Windows, Unix ?

Maybe there are some build-in functions for doing this ? An example would be nice.

Thanks.
Death
Forum Newbie
Posts: 17
Joined: Tue Apr 19, 2005 11:52 am

Post by Death »

I think I found it.

I can use explode() or split().

Does anyone know which is faster ?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Why don't you give it a try? And let us know what your findings are :) And tell us if the differences are significant enough to care about ;)
Post Reply