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
这些是常用的字符串操作函数, ......
如果您尚未打算用 OO 原则创建应用程序,则使用 PHP 的面向对象(OO)的语言特性,这 7 个习惯将帮助您开始在过程编程与 OO 编程之间进行转换。
在 PHP 编程早期,PHP 代码在本质上是限于面向过程的。过程代码 的特征在于使用过程构建应用程序块。过程通过允许过程之间的调用提供某种程度的重用。
但是,没有面向对象的语 ......
这里50个有益的PHP工具,可以大大提高你的编程工作:
调试工具
Webgrind
Xdebug
Gubed PHP Debugger
DBG
PHP_Debug
PHP_Dyn
MacGDBp
测试和优化工具
PHPUnit
SimpleTest
Selenium
PHP_CodeSniffer
dBug
PHP Profile Class
文档工具
phpDocumentor
PHP DOX
安全工具
Securimage
:验证码工具。
Scave ......