webmaster
webmaster

Reputation: 185

php pregsplit regex for parenthesis

I have string like this:

(17:1)(1:0)(5:0)

How can I get to array like this:

Array ( 
[0] => 17:1 
[1] => 1:0
[2] => 5:0
)

Upvotes: 1

Views: 174

Answers (1)

webmaster
webmaster

Reputation: 185

My solution (preg_split):

$result = preg_split("/\)/", str_replace("(","",substr($mystring,0,-1)));

Thanks to Casimir et Hippolyte for explode example:

$result = explode(')(', trim($str, '()'));

Upvotes: 1

Related Questions