If I had a url such as www.example.com/test/example/product.html
How would I be able to get just the test part(so the top level)
I understand you would use $_SERVER['REQUEST_URI'] and maybe substr or trim
But I am unsure of how to do this, thank you!
Split the string into an array with
explode, and then take the part you need.If you use PHP 5.4, you can do
$whatINeed = explode('/', $_SERVER['REQUEST_URI'])[1];