搜索所有[{my value here}]并将它们放在PHP中的数组中

I have the following HTML code below, which acts as a template for a module on my php application. The following HTML code is stored as the string:

$parsedTemplate

Here is the HTML

<td>
    [{item3}]
</td>

<td>
    [{item2}]
</td>

<td>
    [{item3}]
</td>

I want php to search the $parsedTemplate string and make an array like the following

'item1','item2','item3'

How can I achieve this in an efficient way? Regex maybe?

Try this regex:

(?s)\[{\K.*?(?=}])

Regex live here.

Explaining:

(?s)      # allows . to match new line
\[{       # your open-delimiter
\K        # you do not need the delimiter, then clear it
.*?       # till the first-next occurrence where
(?=}])    # is possible to see the close-delimiter

Hope it helps.


Edit: To test, it would be like:

preg_match_all('/(?s)\[{\K.*?(?=}])/', $parsedTemplate, $match);
print_r($match);