获取子字符串中最后一个字符的位置

时间:2015-05-11 23:56:41

标签: php string substring echo

$big = "new york city";
$small ="or";
$pos = strpos($big, $small);
echo $pos;

返回5但我希望它返回6,这是“r”的位置。提前致谢

1 个答案:

答案 0 :(得分:-1)

$big = "new york city";
$small ="or";
$pos = strpos($big, $small);
$pos = $pos + strlen($small) - 1;

echo $pos;
相关问题