Hi to all,
This is driving me nuts! A little piece of code that I can't seem to debug :( Basically I have an HTML file in a string and I want to find X inside until another X (same value) IF there is another one, if there isn't, then grab X until end of file.
The code that doesn't work:
$contents = "< div id="main" class="clearfix"> < div id="col-1">< div id="content">< div id="p19601634">< h1>< span id="ppt19601634">";
$regex = "!<div id="content">(.*?)(?:<div id="content">)!s";>
preg_match_all($regex, $contents, $matches);
Please notice that I added spaces before the DIV for display purpose and that I want to check with NEW LINES and TABS inside the HTML also (basically, there is a line return after the first DIV).
Right now, my code works if it finds many occurences of my search and it will return the searches. But if there is only one item found, it doesnt work.
Does someone knows this?
Thanks a bunch