I need some way of capturing the text between square brackets. So for example, the following string:
[This] is a [test] string, [eat] my [shorts].
Could be used to create the following array:
Array (
[0] => [This]
[1] => [test]
[2] => [eat]
[3] => [shorts]
)
I have the following regex, /\[.*?\]/
but it only captures the first instance, so:
Array ( [0] => [This] )
How can I get the output I need? Note that the square brackets are NEVER nested, so that's not a concern.