/ Published in: PHP

Brings single or multiple results from a mediawiki search back as an easy to use array
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function curlStart($url){ curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; he; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8"); return $page; } function findWikiInfo($s) { $page = curlStart("http://en.wikipedia.org/w/api.php?action=opensearch&search=".urlencode($s)."&format=xml&limit=10"); array_push($wikiarray, array((string)$xmlpage->Section->Item->Text, (string)$xmlpage->Section->Item->Description, (string)$xmlpage->Section->Item->Url)); return $wikiarray; } else { array_push($wikiarray, array((string)$xmlpage->Section->Item[$i]->Text, (string)$xmlpage->Section->Item[$i]->Description, (string)$xmlpage->Section->Item[$i]->Url)); } return $wikiarray; } }
Comments
