tags:

views:

34

answers:

2

Hey, I need help isolating part of a url in PHP.

say I have

http://www.test.com/something/something/important/

How could I isolate the "important"

Thanks!

+4  A: 

Use the basename() function for that.

echo basename('http://www.test.com/something/something/important/');

Result:

important
Sarfraz
why is this answer voted down? got the same idea in mind.
Hanseh
The post was edited, I downvoted before it was changed.
Sjoerd
@Sjoerd: agreed, my previous answer was rather quick without checking it.
Sarfraz
+2  A: 
<?php
$url ='http://www.test.com/something/something/important/';
echo basename($url);
?>
Sjoerd