关于字符串成为数组使用

WBOY
Release: 2016-06-13 13:06:54
Original
786 people have browsed it

关于字符串变为数组使用
$str = "a=1 & b=2 & c=3";
上面的 $str 变量,我应该使用一个什么函数,能直接将 a=1 b=2。。。 变为数组形式呢?即可以直接用 $param['a']来获取到 值 1;

------解决方案--------------------
$str = "a=1 & b=2 & c=3";
parse_str($str,$ar);
print_r($ar);
/*
Array
(
[a] => 1
[b] => 2 
[c] => 3
)
*/

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!