PHP头条
热点:

惯用的php代码,hash,split,unset


常用的php代码,hash,split,unset
[size=large]
40)
    #   return ;
    #echo 
   
    $line = preg_replace("/\\n/","",$line); 
    #echo $line; 
    $arr = explode("",$line);
    if (count($arr)<2)
        continue;
    $query=$arr[0];
    $ids=$arr[1];

    $arrID = explode("",$ids);

    $len=count($arrID);

    $str="";
    unset($hash);
    for ($i=0; $i<$len; $i++) 
    {
        $title=getTitle($db,$arrID[$i]);

        $words = explode("",$title);
        foreach($words as $word)
        {
            //echo $word;
            //判断是不是在hash词典中
            if( isset($hash[$word]))
            {
                $hash[$word] = $hash[$word]+1;
            }
            else
            {
                $hash[$word] =1 ;
            }
        }
    }

    $i=0;
    //遍历hash数据结构
    foreach ($hash as $key=>$val)
    {
        if( $i ==0)
        {
            $str=$key."\x03".$val;
            $i =1;
        }
        else
        {
            $str = $str."\x02".$key."\x03".$val;
        }
       
    }
    //字符串拼接
    echo "qf".$query."\x01".$str."\n";
}

fclose($file_handle);

?>


[/size]

www.phpzy.comtrue/phprm/27092.htmlTechArticle惯用的php代码,hash,split,unset 常用的php代码,hash,split,unset [size=large] 40) # return ; #echo $line = preg_replace("/\\n/","",$line); #echo $line; $arr = explode("",$line); if (count($arr) $val) { if( $i ==0) { $str=...

相关文章

PHP之友评论

今天推荐