Reputation: 21
Like this post I need to split on brackets.
But I also need to lose the brackets..
%%%%%%[%%%%][%%%%%%%%]
into:
array {
[0] -> %%%%%%
[1] -> %%%%
[2] -> %%%%%%%%
}
Upvotes: 2
Views: 112
Reputation: 26930
This is so easy that you can even get away with match I think :
preg_match_all('/[^[\]]+/', $subject, $result);
$result = $result[0];
$result will have all your matches.
Upvotes: 2
Reputation: 455000
You can use:
preg_split('/[[\]]+/', $str,-1,PREG_SPLIT_NO_EMPTY)
Upvotes: 2