PHP的http_build_query

http_build_query:生成 URL-encode 之后的请求字符串   把数组转化为querystring形式

第一个参数是要转化的数 第二个是key的前缀 第三个是分隔符

'bar',
              'baz'=>'boom',
              'cow'=>'milk',
              'php'=>'hypertext processor');
echo http_build_query($data) . "\n";
echo http_build_query($data, '', '&');

foo=bar&baz=boom&cow=milk&php=hypertext+processor
foo=bar&baz=boom&cow=milk&php=hypertext+processor



 'milk', 'php' =>'hypertext processor');
echo http_build_query($data) . "\n";
echo http_build_query($data, 'myvar_');

0=foo&1=bar&2=baz&3=boom&cow=milk&php=hypertext+processor
myvar_0=foo&myvar_1=bar&myvar_2=baz&myvar_3=boom&cow=milk&php=hypertext+processor

 

 

 

你可能感兴趣的:(PHP)