Reputation: 1026
This is my string that I need to work with parse_str:
type%3Dbasic%26WhatPropType%3DSingle%2BFamily%2BResidential%26WhatDistrict%255B0%255D%3DHaiku%26WhatStartPrice%3D90000%26WhatEndPrice%3D30000000%26WhatStartBed%3D%26WhatStartBath%3D0%26DaysAgo%3D%26WhatStartIntArea%3D%26WhatSortDirection1%3DDESC%26start%3D0%26WhatNumber%3D10
How can i get this to work?
Upvotes: 1
Views: 1067
Reputation: 552
as the same as our friends say decode the string
parse_str(urldecode('type%3Dbasic%26WhatPropType%3DSingle%2BFamily%2BResidential%26WhatDistrict%255B0%255D%3DHaiku%26WhatStartPrice%3D90000%26WhatEndPrice%3D30000000%26WhatStartBed%3D%26WhatStartBath%3D0%26DaysAgo%3D%26WhatStartIntArea%3D%26WhatSortDirection1%3DDESC%26start%3D0%26WhatNumber%3D10'), $array);
and get value like this
$array['type'] //out put "basic"
Upvotes: 0
Reputation: 27628
You firstly need to decode your url, then pass it to parse_str
. The second parameter for parse_str
is what will be populated with your data. So you can do the following:
parse_str(urldecode('type%3Dbasic%26WhatPropType%3DSingle%2BFamily%2BResidential%26WhatDistrict%255B0%255D%3DHaiku%26WhatStartPrice%3D90000%26WhatEndPrice%3D30000000%26WhatStartBed%3D%26WhatStartBath%3D0%26DaysAgo%3D%26WhatStartIntArea%3D%26WhatSortDirection1%3DDESC%26start%3D0%26WhatNumber%3D10'), $array);
var_dump($array);
will output
array(12) {
["type"]=>
string(5) "basic"
["WhatPropType"]=>
string(25) "Single Family Residential"
["WhatDistrict"]=>
array(1) {
[0]=>
string(5) "Haiku"
}
["WhatStartPrice"]=>
string(5) "90000"
["WhatEndPrice"]=>
string(8) "30000000"
["WhatStartBed"]=>
string(0) ""
["WhatStartBath"]=>
string(1) "0"
["DaysAgo"]=>
string(0) ""
["WhatStartIntArea"]=>
string(0) ""
["WhatSortDirection1"]=>
string(4) "DESC"
["start"]=>
string(1) "0"
["WhatNumber"]=>
string(2) "10"
}
Upvotes: 3