首页 > 代码库 > php 将数组转换网址URL参数

php 将数组转换网址URL参数


$array =array ( ‘id‘ =123, ‘name‘ = ‘dopost‘ );
echo http_build_query( $array );
//得到结果
id=123name=dopost

举例子如下: 复制代码 代码如下: $url
= "http://www.electrictoolbox.com/php-extract-domain-from-full-url/"; $parts = parse_url($url); 输出: 复制代码 代码如下: Array ( [scheme] => http [host] => www.electrictoolbox.com [path] => /php-extract-domain-from-full-url/ ) 又如: 复制代码 代码如下: <?php $url = http://username:password@hostname/path?arg=value#anchor; print_r(parse_url($url)); echo parse_url($url, PHP_URL_PATH); ?> 输出: 复制代码 代码如下: Array ( [scheme] => http [host] => hostname [user] => username [pass] => password [path] => /path [query] => arg=value [fragment] => anchor )

 

php 将数组转换网址URL参数