0

I have <input type="text" name="info"> with the value like this:

array() {
      [name]=> 'Tien'
      [sex]=> 'male'
      [address]=> 'ABC'
      [code]=> '888'
    }

I submit this input to another site (Note that the input value is a string), all I want is convert that value from string back to array array("name"=>"Tien", "sex"=>"male", "address"=>"ABC", "code"=>888). Is possible to convert the string back to array. If yes please help me solve this. Thanks and sorry because my bad English

1
  • How did you come up with this specific format exactly? As deceze said it doesn't seem to be easily serializable.. Commented Jun 27, 2014 at 13:16

2 Answers 2

2

What you're asking for is serialisation, i.e. expressing an arbitrarily complex data structure in the lowest common denominator as text. If you simply choose a serialisation format which can easily be serialised and unserialised, this is trivial. I'd suggest to use either serialize and unserialise or json_encode and json_decode. Whatever format you came up with there is simply not easily unserialisable.

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

Comments

2

I can't completely understand your question, but from my best guess, use this form data:

<input type="text" name="info[name]" value="Tien" />
<input type="text" name="info[sex]" value="male" />
<input type="text" name="info[address]" value="ABC" />
<input type="text" name="info[code]" value="888" />

The other site can then handle it as an array stored within $_POST['info']

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.