Q:

Remove URL part and file extension with strstr

I tried function: strstr, but it has one problem. Suppose, the URL looks like:
http://www.example.com/index.php

With strstr, I am able to remove anything before '/', but I want just:
index
i.e., the actual name of the file without extension.

A:

I would highly suggest using the PHP parse_url() function:
$address = 'http://www.example.com/index.php';
$url = parse_url($address);
echo $url['host'];

There is no point reinventing the wheel.

A:

If the file type can change and you are sure there are no other . in the file name e.g. index.2.php then you can use
$filename = basename('http://www.example.com/index.php');
$filename = substr($filename, 0, strpos($filename, '.'));

A:

If it always ends in .php you can do:
basename('http://www.example.com/index.php', '.php')

If it can end with other extensions, you can do:
if (preg_match('#([^/]+)\.\w+$#', 'http://www.example.com/index.php', $matches))
    $basename = $matches[1];

