您好,我有一个字符串
$str = "[10-1],[20-2],[30-3],";
这我想将int两个数组拆分为-
Array1
(
[0] => 10
[1] => 20
[2] => 30
)
Array2
(
[0] => 1
[1] => 2
[2] => 3
)
怎么做?我的变量$ str依值而异。
谢谢..
使用正则表达式拆分它:
$str = "[10-1],[20-2],[30-3],";
$matches = array();
preg_match_all('/\[(\d+)-(\d+)\],/', $str, $matches);
如果您unset($matches[0]);
剩下的正是您所要求的。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句