Can you please tell me how to cut the file name at the end of the link, i.e. There is a similar reference in the variable:

$url = 'https://ru.stackoverflow.com/questions/ask/index.php'; 

The file name can be any, I need to get everything that goes before index.php for this example. The result is needed - https://ru.stackoverflow.com/questions/ask/

    1 answer 1

    Something like this?

     $url = 'https://ru.stackoverflow.com/questions/ask/index.php'; echo preg_replace("/[^\/]+$/", "", $url);