这是我需要使用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
我怎样才能让它发挥作用?
答案 0 :(得分:3)
首先需要解码您的网址,然后将其传递给parse_str
。 parse_str
的第二个参数是将填充数据的内容。所以你可以做到以下几点:
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);
将输出
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"
}
答案 1 :(得分:1)
parse_str(urldecode($yourString));
答案 2 :(得分:0)
和我们的朋友一样说解码字符串
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);
并获得这样的价值
$array['type'] //out put "basic"