PHP Explode() example

This function is extremely useful when you need to deal with url variables that you need to explode and use the separately. Let me give you a simple example: you have the following url –

Sometimes you need to use the date in the url and other times you need to move the year at the back of the string to use it in another way somewhere in your code.

We can use the PHP explode() function to do this… but first, you need to get the url as a string, you can use this article to learn how to do that – Get actual link of website PHP, after you have the url, you need to isolate the exact string to use it separately.

In our study case we will use the variable in the url that you can get it by accessing $_GET[‘variable_name’].

After we have the $_GET var, we will use the explode function:

You can see this example in action here: php explode(); example