How can I extract the following parts using PHP function:
- The Domain
- The path without the file
- The file
- The file with Extension
- The file without Extension
- The scheme
- The port
- The query
- The fragment
- (add any other that you think would be useful)
Ex.1 https://stackoverflow.com/users/test/login.php?q=san&u=post#top
- The Domain (stackoverflow.com)
- The path without the file (/users/test/)
- The file(login.php)
- The file Extension (.php)
- The file without Extension (login)
- The scheme(https:)
- The port(return empty string)
- The query(q=san&u=post)
- The fragment(top)
Ex: 2 stackoverflow.com/users/test/login.php?q=san&u=post#top
- The Domain (stackoverflow.com)
- The path without the file (/users/test/)
- The file(login.php)
- The file Extension (.php)
- The file without Extension (login)
- The scheme(return empty string)
- The port(return empty string)
- The query(q=san&u=post)
- The fragment(top)
Ex: 3 /users/test/login.php?q=san&u=post#top
- The path without the file (/users/test/)
- The file(login.php)
- The file Extension (.php)
- The file without Extension (login)
- The query(q=san&u=post)
- The fragment(top)
- For remaining (return empty string)
Ex: 4 /users/test/login?q=san&u=post#top
- The path without the file (/users/test/)
- The file(login)
- The file Extension (return empty string)
- The file without Extension (login)
- The query(q=san&u=post)
- The fragment(top)
- For remaining (return empty string)
Ex: 5 login?q=san&u=post#top
- The file(login)
- The file Extension (return empty string)
- The file without Extension (login)
- The query(q=san&u=post)
- The fragment(top)
- For remaining (return empty string)
Ex: 6 ?q=san&u=post
- The query(q=san&u=post)
- For remaining (return empty string)
I checked parse_url function, but doesn't return what I need. Since, I'm beginner in PHP, it was difficult for me. If you have any idea, please answer.
Thanks in advance.