使用strstr删除URL部分和文件扩展名

RKh*_*RKh 0 php

我试过函数:strstr,但它有一个问题.假设,URL看起来像:

http://www.example.com/index.php
Run Code Online (Sandbox Code Playgroud)

使用strstr,我可以在'/'之前删除任何内容,但我想要:

指数

即,没有扩展名的文件的实际名称.

cle*_*tus 6

我强烈建议使用PHP parse_url()函数:

$address = 'http://www.example.com/index.php';
$url = parse_url($address);
echo $url['host'];
Run Code Online (Sandbox Code Playgroud)

没有必要重新发明轮子.