PHP单独的URL字符串 [英] PHP Separate URL String
问题描述
我有一个非常简单的问题,我无法使用在线帮助来解决...
I have a really simple question that I couldn't solve using online help...
我有一个网址,例如"www.google.com/hello/xxxxxxxx"
Well I have an URL, eg. "www.google.com/hello/xxxxxxxx"
我想做的是获取xxxxxxx并打印出来.我已经使用SQL语句收集了要拆分的页面的URL,现在将其存储在$ row ['url']中. 我试图让它在到达"/"时分裂开来.
What I'm trying to do is get that xxxxxxx and print it. I have already gathered the URL of the page I want to split with a SQL statement, and it is now stored in the $row['url']. I have tried to get it it split when it reaches an "/"
这是我现在的代码:
$url = preg_split("[/.-]", $row['url']);
print_r($url);
但这不起作用吗?现在,它什至没有打印任何内容...而且我不知道还能尝试什么!
But it doesn't work? Right now it doesn't even print anything... and I don't know what else to try!
推荐答案
这是您要寻找的吗?
$url = "www.google.com/hello/xxxxxxxx" ;
echo substr( strrchr( $url, '/' ), 1 );
输出:xxxxxxxx
Output: xxxxxxxx
这篇关于PHP单独的URL字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!