赣南脐橙

佰草伐

导航

php 数组与URL相互转换

php为了数组与url参数相互转换提供了两个函数:

1,数组转换为带&的URL的字符串

  例如:

$arr =['title'=>'我是小白','name'=>'真的很白','text'=>'但是决不放弃'];
$res =urldecode(http_build_query($arr));
var_dump($res);exit;

  

结果为:

string(60) "title=我是小白&name=真的很白&text=但是决不放弃";

  

2,带&的URL的字符串转换为数组php知识网

  例如:

$str = "title=我是小白&name=真的很白&text=但是决不放弃";
parse_str($str, $res); //第一个参数为字符串,第二个参数为结果
var_dump($res);
exit;

  

posted on 2020-08-20 16:16  佰草伐  阅读(160)  评论(0编辑  收藏  举报

自定义导航网站

php基础知识

Wood Furniture