Reputation: 6645
How can I search a string for a tag inside [ ] with parameters? So, for example, my string may have in it somewhere:
[tag id='1,2,5']
The numbers in the id parameter could be anything. I want to search to see if the tag is present and if so extract the numbers in the id paramter.
Upvotes: 0
Views: 52
Reputation: 254886
preg_match_all("~\[tag\s+id='([^']+)'\]~", $str, $matches);
var_dump($matches);
Upvotes: 1