优酷指数关键字算法

优酷指数关键字算法

public function query($keywords){

		$keywords = strtolower($keywords);//lowercase 
		$basewords = '';

		$reg0 = '/,/i';
		$keywords = preg_replace($reg0, ',', $keywords);
		$words = explode(',', $keywords);

		for($i=0;$i<sizeof($words);$i++){
			$word = base64_encode(trim($words[$i]));
			$basewords .= $word.",";
		}

		$reg = '/\+/i';
		$reg2 = '/\=/i';
		$reg3 = '/\//i';

		$basewords = preg_replace($reg, '%2b', $basewords);
		$basewords = preg_replace($reg2, '%3d', $basewords);
		$basewords = preg_replace($reg3, '-', $basewords);

		$basewords = substr($basewords,0,strlen($basewords)-1);

		return $basewords;
	}

 

你可能感兴趣的:(优酷指数关键字算法)