如何删除前几个字母并打印 php 中的最后一个标题
How to remove first few letter and print the last title in php
我有永久链接和页面标题。我需要删除唯一的永久链接并使用 PHP 打印标题。
这是代码:
$string = "http://example.com/blog/PageTitle"
从这里删除 http://example.com/blog/
并仅打印 PageTitle
我试过了:
$string = 'http://example.com/blog/PageTitle';
$remove_text = 'http://example.com/blog/'
$count = strlen($remove_text)
echo substr($string, $count);
N.B: 我的 $string
和 pageTitle
可以像 http://example.com/about/PageTitle
, http://example.com/contact/PageTitle2
等一样变化
试试这个
$string = strrev($string);
$str_arr = explode ("/", $string);
$pageTitle = $str_arr[0];
$pageTitle = strrev($pageTitle);
echo $pageTitle;
这应该有效。
我有永久链接和页面标题。我需要删除唯一的永久链接并使用 PHP 打印标题。
这是代码:
$string = "http://example.com/blog/PageTitle"
从这里删除 http://example.com/blog/
并仅打印 PageTitle
我试过了:
$string = 'http://example.com/blog/PageTitle';
$remove_text = 'http://example.com/blog/'
$count = strlen($remove_text)
echo substr($string, $count);
N.B: 我的 $string
和 pageTitle
可以像 http://example.com/about/PageTitle
, http://example.com/contact/PageTitle2
等一样变化
试试这个
$string = strrev($string);
$str_arr = explode ("/", $string);
$pageTitle = $str_arr[0];
$pageTitle = strrev($pageTitle);
echo $pageTitle;
这应该有效。