How can I get the current web directory from the URL?

后端 未结 5 908
[愿得一人]
[愿得一人] 2021-01-28 03:09

If I have a URL that is http://www.example.com/sites/dir/index.html, I would want to extract the word \"sites\". I know I have to use regular expressions but for some reason my

5条回答
  •  无人及你
    2021-01-28 03:34

    The dirname function should get you what you need

    http://us3.php.net/manual/en/function.dirname.php

    
    

提交回复
热议问题