title: Wikipedia search api with much side information
body: <p>I want to take some information about my query from wikipedia using php. I want to have a description, title, img url (if exists), and some side information about it. For example like the google wikipedia information, with much side information.</p>
  
  <p>Until now i have only the description &amp; title.</p>
  
  <p>My code:</p>
  
  <pre><code>        $q = str_replace("#", "", ucwords($query));
          $opts = array('http' =&gt;
            array(
              'user_agent' =&gt; 'Mozilla Firefox www (http://www.mozilla.org)'
            )
          );
          $context = stream_context_create($opts);
          $url = 'en.wikipedia.org/w/api.php?action=opensearch&amp;search='.$q.'&amp;limit=1&amp;namespace=0&amp;format=xml';
          @$wiki_arr = simplexml_load_file($url);
          if(@$wiki_arr-&gt;Section-&gt;Item-&gt;Text == "" or @strtolower($wiki_arr-&gt;Section-&gt;Item-&gt;Text) != strtolower($q))
          {
              return "";
          }
  
          $title = $wiki_arr-&gt;Section-&gt;Item-&gt;Text;
          $description = $wiki_arr-&gt;Section-&gt;Item-&gt;Description;
          $url = $wiki_arr-&gt;Section-&gt;Item-&gt;Url;
          $result = "".$title.", ".$description.", ".$url."";
  </code></pre>