BMH子串查找算法(PHP实现)
代码interface StringSearchable
{
public function search($substring, $buffer);
}
class BoyerMooreStringSearch implements StringSearchable
{
public $substring = null;
public $buffer = '';
public $jumpTable = array();
protected $results = array();
public function __construct()
{
}
public function __destruct()
{
}
public function search($substring, $buffer)
{
$this->results = array();
$this->substring = $substring;
$this->buffer = $buffer;
$this->deriveJumpTable();
$substringLen = strlen($this->substring);
$currentCharIndex = $substringLen - 1;
$bufferLen = strlen($this->buffer);
while ($currentCharIndex < $bufferLen) {
for ($i = $substringLen - 1; $i >= 0; $i--) {
&nb
相关文档:
PclZip简介
PclZip是一个很强大的压缩与解压缩zip文件的PHP类,PclZip library能够压缩与解压缩Zip格式的压缩档(WinZip、PKZIP);且能对此类类档案进行处理,包括产生压缩档、列出压缩档的内容以及解压缩档案等等。
简单、易用、强大是我对它的评价。
最近在开发我的Wordpress插件ShareLink,在这过程中,发现了PclZ ......
<?php
/**
* 把一个汉字转为unicode的通用函数,不依赖任何库,和别的自定义函数,但有条件
* 条件:本文件以及函数的输入参数应该用utf-8编码,不然要加函数转换
* 其实亦可轻易编写反向转换的函数,甚至不局限于汉字,奇怪为什么PHP没有现成函数
* @author xieye
*
* @param {string} $word 必须是一个汉 ......
1 文件结构
|
|――images
|――include
|――parameter
|――config
|――function
|――index
images存放图片文件,include中是系统是要引用的文件,一般在parameter中存放参数文件,config中存放配置文件,function中存放方法文件,如javascript的方法等,并按功能模块的分类,将各功能的类也放入其 ......
1.下载安装mcrypt
先去http://www.sourceforge.net下载Libmcrypt,mhash,mcrypt安装包
2 .先安装Libmcrypt
#tar -zxvf libmcrypt-2.5.8.tar.gz
#cd libmcrypt-2.5.8
#./configure
#make
#make install
说明:libmcript默认安装在/usr/local
3.安装mhash
#tar -zxvf mhash-0.9.9.9.tar.gz
#cd mhash-0.9.9.9
#./ ......
最近在学PHP ,觉得比较简单,可能是因为有一点编程经验的缘故吧,今天教大家用PHP制作通讯录,功能比较简单,第一次做网页教程,而且不是很有PHP经验,所以不足的地方大家留言告诉我,废话不多说,现在开始
环境:Windows XP SP3 + PHP5 + apache2 + mysql5
首先创建一个数据库,名为 MyDB (我这里使用的是MySQL),SQL ......