0

I have a form users fill out that has one textarea. This gets stored in the database.

Now I want to sift through the data collected, get meaningful information out (like title) and store those in new fields in the database.

I know how to get the data out and store it in a variable. I'm not sure what to do next. I need to search the data for specific words like "title" and "instructions" and then focus in on everything after that word until a return was entered. Where should I start with this?

UPDATE

I really like the help so far, the expression match and preg_match_all / preg_match seem to get me started. One last question - I get how to find the start of the search, but how would I find the end? Usually the end will be denoted by a return (enter was pressed)

1
  • If title and Instructions are the fields on the form but you want to process it later i.e. saving in database .... you can json_encode($_POST) array and save it in database and then whenever you want to process just decode it and you will get post array as user have submitted Commented Mar 26, 2014 at 13:12

4 Answers 4

2

If there's any consistency to the text you can use a regular expression.

Otherwise you may want to update the form. Having to rely on consistent user input in a text field is iffy at best.

Sign up to request clarification or add additional context in comments.

1 Comment

oh I know this, we're running a split test between two different forms to see if more fields impact user submission. I'm guessing it won't, but need to still handle cases that are coming from the old form.
1

First of all, get data to a variable, then search in this variable to extract your data. The best way to do this is with Regular expression and with php functions preg_match and preg_match_all

EDIT: For your second question you can search with regular expression to find \r and \n characters.

Comments

0

you can achieve this by using Explode() function. Split the fields by using the separator. After converting the string to array, then you can parse the array again to get the Heading and value.

Comments

-1

preg_match_all would be a good starting point.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.