I use the following code to grab the text between these two tags.
Expand|Select|Wrap|Line Numbers
- $content = "[tag]Hello[/tag]";
- preg_match_all("/(\[([\w]+)\])(.*)(\[\/\\2\])/", $content, $matches);
- print_r($matches);
Expand|Select|Wrap|Line Numbers
- Array
- (
- [0] => Array
- (
- [0] => [tag]Hello[/tag]
- )
- [1] => Array
- (
- [0] => [tag]
- )
- [2] => Array
- (
- [0] => tag
- )
- [3] => Array
- (
- [0] => Hello
- )
- [4] => Array
- (
- [0] => [/tag]
- )
- )
Expand|Select|Wrap|Line Numbers
- $content = "[tag]Hello[/tag] More Text [tag]Hello2[/tag]";
- preg_match_all("/(\[([\w]+)\])(.*)(\[\/\\2\])/", $content, $matches);
- print_r($matches);
Expand|Select|Wrap|Line Numbers
- Array
- (
- [0] => Array
- (
- [0] => [tag]Hello[/tag] More Text [tag]Hello2[/tag]
- )
- [1] => Array
- (
- [0] => [tag]
- )
- [2] => Array
- (
- [0] => tag
- )
- [3] => Array
- (
- [0] => Hello[/tag] More Text [tag]Hello2
- )
- [4] => Array
- (
- [0] => [/tag]
- )
- )