in the code snippet I just wrote, before using the array_pop() function, call
print_r($url_parts_array);
and notice that those parts are all nicely stripped out for you
array_pop(), just grabs the last value of the array, which is why I suggested it because I thought that was the only value you needed.