php 字符串 以 开头 以结尾 startWith endWith
时间:2015-10-22 14:08:04
收藏:0
阅读:5147
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);
}
原文:http://www.cnblogs.com/joeblackzqq/p/4900563.html
评论(0)