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

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

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

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

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

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