您的位置:首页 > 编程语言 > PHP开发

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);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: