I need to create an array by searching a string for occurrences of '[' followed by 0 or more characters followed by ']'.
My test string:
$string="[item 1] [2] [] [item3]";
All of the above must be matched.
I think the regex to do so is
\[*\]
But how do I create an array out of the string? Do I use
preg_match_all("\[*\]", $string, $matches);
?