php 字符串 以 开头 以结尾 startWith endWith
2015-10-22 12:53
676 查看
From: http://www.shipingzhong.cn/node/1217
//第一个是原串,第二个是 部份串
function startWith($str, $needle) {
return strpos($str, $needle) === 0;
}
//第一个是原串,第二个是 部份串
function endWith($haystack, $needle) {
$length = strlen($needle);
if($length == 0)
{
return true;
}
return (substr($haystack, -$length) === $needle);
}
//第一个是原串,第二个是 部份串
function startWith($str, $needle) {
return strpos($str, $needle) === 0;
}
//第一个是原串,第二个是 部份串
function endWith($haystack, $needle) {
$length = strlen($needle);
if($length == 0)
{
return true;
}
return (substr($haystack, -$length) === $needle);
}
相关文章推荐
- PHP stristr()函数
- 采用ThinkPHP3.2.3框架开发网站快速入门
- PHP实现无限级分类(不使用递归)
- PHP实现递归无限级分类
- 如何解决PHP里大量数据循环时内存耗尽的问题
- PHP Notice: undefined index 完美解决方法
- laravel 自定义函数 使用
- laravel 查看SQL语句
- InputStream OutputStream 操作文件
- php 字符串填充函数
- php笔记_autoload call clone destruct
- php curl 请求方法封装
- PHP5 session 详解【经典】 -- 转帖
- Vsftpd配合脚本实现目录配额
- PHP学习笔记之命名空间//待完善V1.0
- yii提示The table "xxx" for active record class "DistAR" cannot be found in the database
- php 图片下载
- php 下设置cookie问题
- 提高PHP编程效率的53个要点
- Esper系列(四)Output