$pattern = '#\[img (([^="\]]+)="([^"]+)" ?)+\]#';
preg_match_all($pattern,$blog,$matches,PREG_PATTERN_ORDER);
[img size="preview" click="http://text.com" align="right" src="pic:3378f.jpg"]
The code at the top matches the BBCode tags like above, but only returns the last attribute, when it should be returning all as per the subpatterns in my regex. What’s the deal?
For this to work you have to match the
[img]block first:You memorize the pattern inside the tag and use another loop to extract the parameters, using another
preg:Output: