I’m trying to extract all content of below string starting from tag [caption] to tag [/caption] including the tags. Preg_match_all seems to me the most adequate function. Can you help with the pattern please?
Just noticed it’s returning only a single block [caption][/caption]. It can happen that the string has 2 or more. Sorry, I should had mentioned this on my first post.
As to the preg_replace, unfortunately the link was kept.
echo preg_replace("~\[caption(.*?)\](.*?)\[/caption\]~i", "$2", $str);
Some text... <a href="http://www.site.com"><img class="size-full" src="http://www.site.com" alt="pic" width="640" height="345" /><\/a> Photo by ...more text