Forum Moderators: coopster

Message Too Old, No Replies

String Line Parsing

How do you grab a line and delete a line

         

HeadBut

5:02 pm on Oct 21, 2004 (gmt 0)

10+ Year Member



I have form text I need to parse and process. When I use sscanf to get a line it doesn't always act the same.

$data = sscanf($IncommingDATA, "%s\r");

My incomming data is like a file with tabs between items and return ending a line. The php functions don't seem to like this and often work backwards than I exspect?
Someone got a way to grab a line parse it and grab the next line?
Note: Text from a form not a file!

Thanks

coopster

7:01 pm on Oct 21, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



When you say the text is from a form, do you mean a form <input> element, or maybe even a <textarea>?

HeadBut

9:03 pm on Oct 21, 2004 (gmt 0)

10+ Year Member



Yea from a <textarea>

coopster

10:19 pm on Oct 21, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I'm not sure how you are getting tabs into a <textarea>...? Every time a user would hit the tab key, it should move them onto the next form element.

To parse the newlines in a text area, maybe you could use explode() [php.net] on the variable value for the textarea?

HeadBut

3:32 pm on Oct 22, 2004 (gmt 0)

10+ Year Member



Tabs paste into a textarea with any other text... that's easy!

coopster

3:39 pm on Oct 22, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Ah yes, cut and paste. Well, explode it again on tabs then ;)