Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $json = json_decode(file_get_contents("http://util.xat.com/wiki/api.php?action=query&titles=Errors&prop=revisions&rvprop=content&format=json"), true);
- $wiki = strip_tags($json['query']['pages'][156]['revisions'][0]['*']);
- $splits = preg_split("/\n?==\s?(.*?)\s?==\n?/", $wiki, -1, PREG_SPLIT_DELIM_CAPTURE);
- array_shift($splits);
- $categories = [];
- for($x = 0; $x < count($splits); $x+=2) {
- preg_match_all("/{{(?:spoiler\|bold=no\|\n)(.*?)}}/s", trim($splits[$x+1]), $m);
- $categories[$splits[$x]] = array_map(function($element) {
- $element = str_replace(" ", " ", $element);
- $element = preg_replace(["/\[\[(\w+)\]\]/", "/\[\[(?:.*?)\|(.*?)\]\]/", "/\[(.*?)\s(?:.*?)\]/"], ["http://xat.wiki/$1", "$1", "$1"], $element);
- $element = explode("|", $element, 2);
- if(count($element) > 1)
- $element[0] .= " More information at http://xat.wiki/Errors.";
- return array_map("trim", $element);
- }, $m[1]);
- }
- print_r($categories);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement