Home >Backend Development >PHP Tutorial > 关于字符串成为数组使用

关于字符串成为数组使用

WBOY
WBOYOriginal
2016-06-13 13:06:54817browse

关于字符串变为数组使用
$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
)
*/

Statement:
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