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
相关文档:
PHP中的字符串操作功能是比较多的,重要的有以下这些:
(1)echo,print,printf,sprintf
前两个函数是输出字符串.字符串中如果有变量名则被替换成其值. 后两个函数类似于C的同名函数.
(2)strchr,strlen,strtok,strrchr,strrev,strstr,strtolower, strtoupper,substr,ucfirst
这些是常用的字符串操作函数, ......
<?php
/**
+++++++++++++++++++++=+++++上传图片++++++++++++++++++++++++++++++++++++++++
—————————————————————————————&mdas ......
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
#./ ......
上一篇中,简单写了个Input.php , 但生日那一栏要自己手动输入写,比较麻烦,所以这里用到一个JS文件,可以选择日期
点击下载这个js文件
在Input.php文件最顶端引用这个JS文件
<script type="text/javascript" src="calenderJS.js"></script>
将生日的输入框改成
<input name="birthday" type="text" ......