0

I pass with jquery ajax as data array the following structure

 $_POST['data'][0] = 'results[]=stein&results[]=schere&results[]=stein&results[]=schere&results[]=stein'

 $_POST['data'][1] = '9b2c1230757e4354b384c5c93e8e8f26'

How do I say to php to interpret $_POST['data'][0] as array. What I would like to get is array(1 =>'stein', 2=>'schere'...)

1
  • this should work $_POST['data'][0][results]... Commented Dec 4, 2012 at 6:52

2 Answers 2

3

Use parse_str() — Parses the string into variables

$str = "results[]=stein&results[]=schere&results[]=stein&results[]=schere&results[]=stein";
parse_str($str, $output);

echo $output['results'][0]; // stein

Live CodePad

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

Comments

0

use parse_str()..

parse_str($_POST['data'][0]);

print_r($results);
echo $results[0];  //stein;
echo $results[1];  //schere;

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.