rendered paste body protected function build_keywords() { $keywords = $this->keywords; $numkw = count($this->keywords); $return = array(); foreach($keywords as $kw) { $url = 'http://www.youtube.com/results?search_query=' . urlencode($kw); $this->cm->add(new CurlRequest($url)); } $this->cm->perform(); for($i=0;$i<=$numkw;$i++) { $kw = $keywords[$i]; $contents = $this->cm->requests[$i]->body; $orig = urlencode($kw); $regex = "/<a href=\"\/results\?orig_query=$kw&search_query=(.*?)\">(.*?)<\/a>/ims"; if(preg_match_all($regex, $contents, $matches, PREG_PATTERN_ORDER)) { foreach($matches[2] as $related) { if( (strstr($related, $kw)) && (!in_array($related, $return)) ) $return[] = $related; if(strstr($kw, ' ')) { $kws = explode(' ', $kw); foreach($kws as $word) { if( (strstr($related, $word)) && (!in_array($related, $return)) ) $return[] = $related; } } } } } return $return; }