String to array or Array to string tips on formats, etc

Posted by user316841 on Stack Overflow See other posts from Stack Overflow or by user316841
Published on 2010-04-14T18:59:41Z Indexed on 2010/04/14 19:03 UTC
Read the original article Hit count: 215

Filed under:

hi, first of all thanks for taking your time!

I'm a junior Dev, working with PHP + mysql.

My issue:

I'm saving data from a form to my database. From this form, there's only need to save the contacts: Name, phone number, address. But, it would be nice to have a small reference to the user answers.

Let's say for each question we've got a value betwee 1 and 4. Since there's no need to create a table just for it, because what's needed is just the personal contacts. I'm thinking of recording each question/answer, as a letter and its correspondent value.

Example (A2, B1, C5, D3, etc).

My question is:

Is there a format I could afterwards, handle easily ? Convert to array (string to array) in case the client change ideas, and ask this data, placed in table columns ? Just to prevent this situation!


From (A2, B1, C5 ) to array( "A" => "1", "B" => "1", "C" => "5" )

    • For now I guess, Regex is the answer, but it's allways hard to figure it out and I'm allways getting in troubles =)


© Stack Overflow or respective owner

Related posts about php

Related posts about string