1

这是我需要使用 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

我怎样才能让它工作?

4

3 回答 3

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"
}
于 2013-06-14T15:54:44.280 回答
1
parse_str(urldecode($yourString));
于 2013-06-14T15:55:17.017 回答
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"
于 2017-07-05T06:05:33.190 回答