I have an HTML string and want to extract content inside a particular tag <selection>
.
Example:
Lorem Ipsum is simply <selection alt="dummy" name="dummy">dummy</selection > text the printing and typesetting <selection alt="industry" name="industry">industry</selection>. Lorem Ipsum has been the industry's <selection alt="standard" name="standard">standard</selection>dummy text ever since the 1500s.
In the above HTML string I need to extract text inside selection
tags, but all tags have different attributes.
Try this:
preg_match_all('/<selection.*?">(.*?)<\/selection.*?>/is',$sourcestring,$matches);
The $matches
is your result in the form of array.