小编Muz*_*fer的帖子

PHP CURL - 空输出,没有错误

我没有获得有效网址的curl输出,示例$ url = http://linkedin.com/pub/4/b29/8a0

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,           "$url");
curl_setopt($ch, CURLOPT_TIMEOUT,       60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

$referer = WebCrawl::getRandomURL();
curl_setopt($ch, CURLOPT_REFERER,       $referer);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_COOKIEJAR,     "cookie.txt");

curl_setopt($ch, CURLOPT_USERAGENT,     "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");

$body = curl_exec($ch);
$error_no = curl_errno($ch);
Run Code Online (Sandbox Code Playgroud)

php curl

6
推荐指数
1
解决办法
1万
查看次数

PHP:比较两句话

我需要比较下面的两个句子,输出应该是匹配的百分比

- 答:高级经理,生产

B:高级经理,生产销售

我试着通过比较句子的每个单词(下面的代码).它有效,但我需要很有效的方式.

public function contact_title_match($old_title,$new_title)
{
   $new_title=preg_replace('/[^a-zA-Z0-9_ %\[\]\.\(\)%&-]/s', '', $new_title);
   $new_title_arr=explode(" ",$new_title);
   $count=count($new_title_arr);
   $index=0;
   if($count>0)
   {
      foreach($new_title_arr as $title_word)
      {
        if(stripos($old_title,$title_word)!==false)
            $index++;
      }
      if(($index/$count)>= 0.5) return 1;
      else                      return 0;
   }
}
Run Code Online (Sandbox Code Playgroud)

php comparison

0
推荐指数
1
解决办法
2009
查看次数

标签 统计

php ×2

comparison ×1

curl ×1