00001 <?PHP
00002
00003 class yahooWebSearch {
00004
00005 private $_clss;
00006
00012 public function __construct(yahooSearch $clss) {
00013 $this->_clss = $clss;
00014 }
00015
00016 private function _resultsXml() {
00017
00018 $res = explode('<Result>', $this->_clss->getResource());
00019 $search = array();
00020
00021 for ($i = 0; $i <= (count($res) - 1); $i++) {
00022
00023 $search[$i]['title'] = $this->_getTagContent($res[$i], 'Title');
00024 $search[$i]['summary'] = $this->_getTagContent($res[$i], 'Summary');
00025 $search[$i]['url'] = $this->_getTagContent($res[$i], 'Url');
00026 $search[$i]['clickurl'] = $this->_getTagContent($res[$i], 'ClickUrl');
00027 $search[$i]['displayurl'] = $this->_getTagContent($res[$i], 'DisplayUrl');
00028 $search[$i]['modificationdate'] = $this->_getTagContent($res[$i], 'ModificationDate');
00029 $search[$i]['mimetype'] = $this->_getTagContent($res[$i], 'MimeType');
00030
00031 $cache = $this->_getTagContent($res[$i], 'Cache');
00032 $search[$i]['cache']['url'] = $this->_getTagContent($cache, 'Url');
00033 $search[$i]['cache']['size'] = $this->_getTagContent($cache, 'Size');
00034
00035 }
00036
00037 return $search;
00038
00039
00040 }
00041
00048 private function _getTagContent($resource, $tag) {
00049 $res = explode('<' . $tag . '>', $resource);
00050 $res1 = explode('</' . $tag . '>', $res[1]);
00051 return $res1[0];
00052 }
00053
00058 public function results() {
00059
00060 return $this->_resultsXml();
00061
00062 }
00063
00064 }
00065
00066 ?>
00067