I have researched the jist behind making this work but I am having a unique problem that I can't seem to fix.
I use the following code to grab the text between these two tags.
This yields the following results succesfully:
The problem arises when there are duplicate tags.
With this I end up with the following:
I need to be able to have it stop at the first close tag and then register the second open and close tag in a different array. Any Ideas?
I use the following code to grab the text between these two tags.
Code:
$content = "[tag]Hello[/tag]";
preg_match_all("/(\[([\w]+)\])(.*)(\[\/\\2\])/", $content, $matches);
print_r($matches);
Code:
Array
(
[0] => Array
(
[0] => [tag]Hello[/tag]
)
[1] => Array
(
[0] => [tag]
)
[2] => Array
(
[0] => tag
)
[3] => Array
(
[0] => Hello
)
[4] => Array
(
[0] => [/tag]
)
)
Code:
$content = "[tag]Hello[/tag] More Text [tag]Hello2[/tag]";
preg_match_all("/(\[([\w]+)\])(.*)(\[\/\\2\])/", $content, $matches);
print_r($matches);
Code:
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]
)
)
Comment