php实现浏览器地址栏字符串转化数组的方法是:使用parse_str()函数来实现,例如【parse_str($query_str,$query_arr);】。
本文操作环境:windows10系统、php 7、thinkpad t480电脑。
在php中要实现浏览器地址栏中的字符串与数组互相转换其实并不难,只要我们合理利用php提供的函数就可以轻松实现。下面我们就来一起看看吧。
$data = array('name' => 'tom','sex' => 1,'channel' => 'ty');
数组转url参数字符串
$querystr = http_build_query($data); echo query_str;
执行结果:
name=tom&sex=1&channel=ty
url参数字符串转数组
parse_str($query_str,$query_arr); print_r($query_arr);
执行结果:
array(name => tom,sex => 1,channel => ty)
推荐学习:php培训
以上就是php怎么实现浏览器地址栏字符串转化数组的详细内容。