仅显示最后一个结果的PHP字符串数组
需要帮助仅显示以下代码中的最后一个数组:仅显示最后一个结果的PHP字符串数组,php,Php,需要帮助仅显示以下代码中的最后一个数组: $string = "localhost/project/vanilla_2/index.php?p=/discussions/MostCommented"; /* Use tab and newline as tokenizing characters as well */ $tok = strtok($string, "/"); while ($tok !== false) { echo "Word=$tok<br />"
$string = "localhost/project/vanilla_2/index.php?p=/discussions/MostCommented";
/* Use tab and newline as tokenizing characters as well */
$tok = strtok($string, "/");
while ($tok !== false) {
echo "Word=$tok<br />";
$tok = strtok("/");
问题:
如何只得到最后的结果?(大部分被推荐)
谢谢我相信您正在尝试从URL获取最后一个字符串。检查以下行
$string = "localhost/project/vanilla_2/index.php?p=/discussions/MostCommented";
$explode_str = explode("/", $string);
echo end($explode_str);
我认为
end($explode)
应该是end($explode\u str)
Yes很有魅力,谢谢:)你们两个都是传奇!
$string = "localhost/project/vanilla_2/index.php?p=/discussions/MostCommented";
$explode_str = explode("/", $string);
echo end($explode_str);