Q:

Php getting all values from the string

By doing ajax I am getting one result in php like this
source_lang_pair[]=EN-NO&source_lang_pair[]=NE-NO&source_lang_pair[]=HI-NO&source_lang_pair[]=OR-NO&source_lang_pair[]=JA-NO&resource_search_name=aa

I want to extract all the values of source_lang_pair and resource_search_name value together.
I have tried parse_str but its not working. So can someone tell me how to extract those values from the string?

A:

parse_str works great like this:
<?php
$str = "source_lang_pair[]=EN-NO&source_lang_pair[]=NE-NO&source_lang_pair[]=HI-NO&source_lang_pair[]=OR-NO&source_lang_pair[]=JA-NO&resource_search_name=aa";
parse_str($str);
echo $resource_search_name;
echo "<br/>";
var_dump ($source_lang_pair);

Output:
aa
array(5) {
  [0]=>
  string(5) "EN-NO"
  [1]=>
  string(5) "NE-NO"
  [2]=>
  string(5) "HI-NO"
  [3]=>
  string(5) "OR-NO"
  [4]=>
  string(5) "JA-NO"
}

or you can use like this for uncertainty:
<?php
$str = "source_lang_pair[]=EN-NO&source_lang_pair[]=NE-NO&source_lang_pair[]=HI-NO&source_lang_pair[]=OR-NO&source_lang_pair[]=JA-NO&resource_search_name=aa";
parse_str($str, $output_array);
var_dump ($output_array);

This time your output will be:
array(2) {
  ["source_lang_pair"]=>
  array(5) {
    [0]=>
    string(5) "EN-NO"
    [1]=>
    string(5) "NE-NO"
    [2]=>
    string(5) "HI-NO"
    [3]=>
    string(5) "OR-NO"
    [4]=>
    string(5) "JA-NO"
  }
  ["resource_search_name"]=>
  string(2) "aa"
}

