How to parse url using php

→ Are you a new visitor? Please visit the page guidance for new visitors ←

How to parse url using php

In certain cases, even in my recent made cpanel plugin, I had to parse the url for me to clear their resource cache. The use cases for this are a lot, there are a lot of manipulation reasons for this as well as solutions.

Scenario

I’ll take the same url from one of our pages:

Solution

I used for this the parse_url function from php, it will give us an array of all the parts from our url:

Output result

Using the array result

From there, you can use the array elements exactly as you wanted / needed. For instance, if you just need the full url, you can use:

That’s it for this, quick, easy and simple!

Request an article ←