需要网址的最后一部分
http://example.com然后最后一部分是什么,如果它是http://example.com/i然后最后一部分是我,如果它是http://example.com/i/am/file.php 然后最后部分是file.php
不确定我是否使用正则表达式或什么
Vas*_*kov 19
这是一个简单的例子:
<?php
$url = "http://example.com/i/am/file.php";
$keys = parse_url($url); // parse the url
$path = explode("/", $keys['path']); // splitting the path
$last = end($path); // get the value of the last element
?>
Run Code Online (Sandbox Code Playgroud)
我希望这能帮到你;)
| 归档时间: |
|
| 查看次数: |
13965 次 |
| 最近记录: |