http_build_query — 生成 URL-encode 以后的请求字符串php
Example #1 http_build_query() 使用示例ui
<?php $data = array('foo'=>'bar', 'baz'=>'boom', 'cow'=>'milk', 'php'=>'hypertext processor'); echo http_build_query($data) . "\n"; echo http_build_query($data, '', '&'); ?>
以上例程会输出:code
<strong>foo=bar&baz=boom&cow=milk&php=hypertext+processor foo=bar</strong>&<strong>baz=boom</strong>&<strong>cow=milk</strong>&<strong>php=hypertext+processor</strong>
parse_str — 将字符串解析成多个变量字符串
Example #1 parse_str() 的使用class
<?php $str = "first=value&arr[]=foo+bar&arr[]=baz"; parse_str($str); echo $first; // value echo $arr[0]; // foo bar echo $arr[1]; // baz parse_str($str, $output); echo $output['first']; // value echo $output['arr'][0]; // foo bar echo $output['arr'][1]; // baz ?>