Given
http://host/test/google/oop/a/a
I’m trying to retrieve the last two elements seperated by / so I can do
$myvar = “a_a”;. There could be an ending / or not it needs to work both ways.
I have the following working but it’s pretty ugly, how else could I do it?
$href = preg_split("/[\/]+/", "http://host/test/google/oop/a/a");
$myvar = $href[count($href)-3] . "_" . $href[count($href)-2];
Alternatively you could do it this way: