Home >Backend Development >PHP Tutorial > 求如何将2个字符串变成一个数组

求如何将2个字符串变成一个数组

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

求怎么将2个字符串变成一个数组?
例如str1= "12,32,3 ";str2= "0,2,1 ";
怎么转化成数组
$result=array{
                              [12]=> 0,
                              [32]=> 2,
                              [3]=> 1                                                  
                                  }

------解决方案--------------------
$result = array_combine(explode(',', $str1), explode(',', $str2));

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