Если у меня есть URL-адрес, вот так:
Http: //wwww.example/test1/test2/test3/
 Как я могу получить строку test3 из url выше? 
 $str = explode("/","http://wwww.example/test1/test2/test3/"); echo $str[count($str)-2]; 
ДЕМО: https://eval.in/83914
Регулярное выражение.
 $url = 'http://wwww.example/test1/test2/test3/'; preg_match('#.*/(.*)/$#', $url, $matches); echo $matches[1]; 
демонстрация
  Используя группу захвата, $ : 
 preg_match('!/([^/]+)/[^/]*$!', 'http://wwww.example/test1/test2/test3/', $matches); echo $matches[1]; 
ДЕМО: http://ideone.com/7EVfZa