在PHP中拆分以下$string
以获取数组$cars
的最佳方法是什么?
$string = '{xa}{y}{z12}{123}{2}{aabb}';
$cars = array("{xa}","{y}","{z12}", "{123}", "{2}", "{aabb}");
我需要每个数组元素都有括号,例如:{xa}
答案 0 :(得分:5)
$string = str_replace("}{","},{",$string);
$x = explode(',',$string);