If I have the following url:
http://URL/products/38/293/bannana_cake/
or
htp://URL/products/38/293/fruit_cake/
How can I isolate just bannana_cake
and fruit_cake
from the examples above?
If I have the following url:
http://URL/products/38/293/bannana_cake/
or
htp://URL/products/38/293/fruit_cake/
How can I isolate just bannana_cake
and fruit_cake
from the examples above?
<?php
$url = 'http://username:password@hostname/path?arg=value#anchor';
print_r(parse_url($url));
echo parse_url($url, PHP_URL_PATH);
?>
And then use explode()
on the 'path' element.
For example:
<?php
$url = 'http://URL/products/38/293/bannana%5Fcake/';
$a = parse_url($url);
$p = explode('/', $a['path']);
echo $p[4];
?>