$str = "北京奥运";
$arrStr = explode("奥运", $str);
if ($arrStr[count($arrStr)] == "") {
echo "y";
}
else {
echo "n";
}比较笨的方法,呵呵。其中你只要知道explode函数的用法就知道这个算法的意思了。
$arrStr = explode("奥运", $str);
if ($arrStr[count($arrStr)] == "") {
echo "y";
}
else {
echo "n";
}比较笨的方法,呵呵。其中你只要知道explode函数的用法就知道这个算法的意思了。
$str2 = "电视";if( strrchr($str,$str2)==$str2 )echo "Y";
else echo "N";
$arrStr = explode("奥运", $str);
if ($arrStr[count($arrStr)-1] == "") {
echo "y";
}
else {
echo "n";
}
很抱歉,之前写的代码是有错误的,$arrStr字符串数组的最后一个应该是count($arrStr) - 1,这个才是数组的最后一个,如果是$arrStr[count($arrStr)],那么判断永远为真
$str = 'abcd';
$end = 'cd';var_export(substr($str, 0-strlen($end)) == $end);