I know this is possible, but for the life of me I can not work it out.
Consider this scenario:
$html = '<tr>
<td>Some Marker I know<td>
<td>This is what I want</td>
<tr>
So a preg_match would be something like:
preg_match_all( '#Some Marker I know<td><td>(.*?)</td>#', $html, $match );
However I can't be sure of certain things, and thus need somethign which allows more flexiability
Example:
$html = '<tr class='unknown another' id='no idea'>
<td attribute='no idea' class='no idea'>Some Marker I know<td>
<label>This is what I want</label>
<tr>
Notice I have changed the: - Classes and ID - which may or may not exist - The html tags - which might not be TDs (might be a DIV) but will always be the next one.
So to be clear what im looking to get is the string 'This is what I want'
In english the search term would be something along the lines of:
- Get me the contents of the next tag/element
- Where the content of the previous element is 'Some Marker I know
- But where the tags inbetween might (or might not) have classes, IDs and so on
I know this isnt the easiest things to example, but I was pretty sure you could use wildcards in this to help it.
Thanks!