I am wanting to grab my product from my url. For example:
http://www.website.com/product-category/iphone
I am wanting to grab the iphone an
If you want to retrieve the last element of the array, you can use the end function. The rest of your code seems to be working.
$endofurl = end($r);
You could also leverage parse_url and strrchr functions to make it more concise:
$endofurl = strrchr(parse_url($url, PHP_URL_PATH), '/');