0

I want to extract more items from infobox from wiki to my site niriv.com

<?php
 header("Content-Type: application/json");
function _145($str){$str=mb_ereg_replace('50px-','150px-',$str);return $str;}
$apkres=file_get_contents('https://en.wikipedia.org/w/api.php?action=query&prop=info|extracts|pageimages|images|Infobox&inprop=url&exsentences=1&titles='.strtolower($_GET['q']).'&format=json');
preg_match_all('@"title":"(.*?)",@sm',$apkres,$str);
$title=$str[1][0];
preg_match_all('@"fullurl":"(.*?)",@sm',$apkres,$str);
$fullurl=$str[1][0];
preg_match_all('@"source":"(.*?)",@sm',$apkres,$str);
$source=_145($str[1][0]);
preg_match_all('@"extract":"(.*?)",@sm',$apkres,$str);
$extract=$str[1][0];
?>{"Abstract":"<?php echo $extract; ?>","AbstractSource":"Wikipedia","AbstractText":"<?php echo $extract; ?>","AbstractURL":"<?php echo $fullurl; ?>","Answer":"","AnswerType":"","Definition":"","DefinitionSource":"","DefinitionURL":"","Entity":"","Heading":"<?php echo $title; ?>","Image":"<?php echo $source; ?>","ImageHeight":200,"ImageIsLogo":0,"ImageWidth":320,"Infobox":"","Redirect":"","RelatedTopics":[],"Results":[],"Type":"A","meta":{}}

Current result: current result via this code above

Resul i want : result i want

Yukesh
  • 1
  • 1
    You know that there's a function to [decode JSON](https://www.php.net/manual/en/function.json-decode.php), right? – Sammitch Jun 14 '23 at 21:21

0 Answers0