HabibS HabibS - 5 months ago 6
PHP Question

how to get nested values inside braces

How to use php to get inside nested braces?


{{ text1 {{text2 text3 {{text4}} text5}} }}

should output

1- text1 {{text2 text3 {{text4}} text5}}
2- text2 text3 {{text4}} text5
3- text4


I've found the answer i was looking for and put this here so everyone could use it. Its very simple indeed, in one line only:


It will search and replace all {{text}} with whatever you want. You can also use the preg_match_all to get all of them in an array.