2013-03-04 26 views

回答

5

使用正则表达式来获得所需的值,然后组合数组来获得关联数组。例如:

$str = 'p10s2z1234'; 

preg_match_all('/([a-z]+)(\d+)/', $str, $matches); //handles only lower case chars. feel free to extend regex 

print_r(array_combine($matches[1], $matches[2])); 
+0

谢谢,它非常有用 – DuyHung 2013-03-04 08:14:22

0

我说你应该把它P,10,S 2,Z,1234和爆炸()

$测试=“P 10,S,2,Z ,1234" ; $ pieces = explode(“,”,$ test);

从那里把它们放到一个数组中。