irishmcbean
New Member
I am having an issue getting a detailed preg_match_all to work. I keep getting a blank Array.Here is my code:\[code\] <?php $remote_search = file_get_contents('http://wiki.seg.org/index.php?title=Special%3ASearch&search=drilling&button='); preg_match_all('%<li><div class=\'mw-search-result-heading\'><a href="http://stackoverflow.com/questions/12813160/(.*)" title="(.*)">(.*)</a> </div> <div class=\'searchresult\'>(.*)</div> <div class=\'mw-search-result-data\'>(.*)</div></li>%si', $remote_search, $links); echo '<ul class=\'mw-search-results\'>'; for($i = 0; $i < count($links[1]); $i++) { echo '<li><div class=\'mw-search-result-heading\'><a href="' . $links[5][$i] . '" title="' . $links[4][$i] . '">' . $links[3][$i] . '<\/a> </div> <div class=\'searchresult\'>' . $links[2][$i] . '<\/div><div class=\'mw-search-result-data\'>' . $links[1][$i] . '<\/div><\/li>'; } echo '</ul>'; ?>\[/code\]I am trying to grab the link details from code shown below:\[code\]<li><div class='mw-search-result-heading'><a href="http://stackoverflow.com/index.php/Dictionary:Cable_drilling" title="Dictionary:Cable drilling">Dictionary:Cable drilling</a> </div> <div class='searchresult'>{{lowercase}}{{#category_index:C|cable <span class='searchmatch'>drilling</span>}}</div><div class='mw-search-result-data'>132 B (22 words) - 19:58, 20 December 2011</div></li>\[/code\] When I perform a \[code\]var_dump($links);\[/code\] I get \[code\]Array\[/code\] as the result.The code below works to grab the contents in the section I am trying to pull the variables.\[code\] <?php $remote_search = file_get_contents('http://wiki.seg.org/index.php?title=Special%3ASearch&search=drilling&button='); preg_match_all('%<ul class=\'mw-search-results\'>(.*)</ul>%si', $remote_search, $links); $bar = $links[0]; echo '<ul class=\'mw-search-results\'>'; echo $bar; echo '</ul>'; var_dump($links); ?>\[/code\]The \[code\]echo $bar;\[/code\] results in \[code\]Array\[/code\] and no ouput.The \[code\]var_dump($links);\[/code\] in this snippet outputs the content of the ul.Does anyone see the error in my top snippet that is preventing me from parsing the code the way I am intending it?