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

WBOY
Release: 2016-06-13 13:03:32
Original
985 people have browsed it

常用的php代码,hash,split,unset
[size=large]

<?php /**
 *
 * @author
 * @version $Id$
 */
// 这个php文件用到了大多数数据处理需要用的功能。
#error_reporting("ALL");
#
$db = tdbm_popen("./id.words.tdbm", O_RDONLY, 0444, 0, 0);


function getTitle($db,$id)
{        
    $relate = tdbm_fetch($db,$id);	
		        
    return $relate;
}
# 读取文件
$file_handle = fopen("./new.fix", "r");

$count =0;
# 遍历文本文件中的行
while (!feof($file_handle)) 
{
    $line = fgets($file_handle);

    #if($count >40)
    #   return ;
    #echo 
   
    $line = preg_replace("/\\n/","",$line); 
    #echo $line; 
    $arr = explode("",$line);
    if (count($arr)",$ids);

    $len=count($arrID);

    $str="";
    unset($hash);
    for ($i=0; $i",$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);

?>


Copy after login
[/size]
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!