怎么获取url中的某段字符串

WBOY
Release: 2016-06-13 13:07:26
Original
1125 people have browsed it

如何获取url中的某段字符串
比如url是: http://localhost/A/B/C.php
我想获取到B这个字符串的值,
请问如何搞定?(最好有代码)
谢谢!

------解决方案--------------------
哦,改一下
$s='http://localhost/A/B/C.php';
$arr=explode('/',pathinfo($s,PATHINFO_DIRNAME ));
echo $arr[count($arr)-1];
------解决方案--------------------
$s = 'http://localhost/A/B/C.php';
$t = explode('/', $s);
echo current(array_slice($t, -2, 1));//B
------解决方案--------------------
echo basename(dirname('http://localhost/A/B/C.php'));

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template