PHP Explode() 获取最后一个句点 (.) 之后的字符串

PHP Explode() get strings after the last PERIOD (.)

我希望有人能帮助我。

我有这个字符串,例如:

But the LORD is in His holy temple. Let all the earth be silent before Him. Habakkuk 2:20

我想使用 explode 函数获取字符串的最后一部分 "Habakkuk 2:20",我的问题是如何告诉 explode 函数选择字符串的最后一个句点 (.)?

就这样。

$str = 'But the LORD is in His holy temple. Let all the earth be silent before Him. Habakkuk 2:20';
$arr = explode('.',$str);
echo end ($arr);

不确定为什么要在这里爆炸。您可以使用 strrpos 函数找到最后一个周期的位置,并获取该位置之后的所有内容:

$str = 'But the LORD is in His holy temple. Let all the earth be silent before Him. Habakkuk 2:20';
$pos = strrpos($str, '.');
echo substr($str, $pos+1);