Reputation: 2551
What is the best way to split the below $string
to get the array $cars
in PHP?
$string = '{xa}{y}{z12}{123}{2}{aabb}';
$cars = array("{xa}","{y}","{z12}", "{123}", "{2}", "{aabb}");
I need each array element with brackets eg : {xa}
Upvotes: 0
Views: 64
Reputation: 38173
$string = str_replace("}{","},{",$string);
$x = explode(',',$string);
Upvotes: 5