-2

Using, PHP I want to get the last part of url (i.e. the part after the last slash).

So,

From:

http://scta.info/resource/person/Aristotle

I would like to just get

Aristotle

Jeff
  • 3,943
  • 8
  • 45
  • 68

1 Answers1

0
$link = 'http://scta.info/resource/person/Aristotle';
$myarray = explode('/',$link);
echo end($myarray);
Ram Sharma
  • 8,676
  • 7
  • 43
  • 56
  • Thanks, that seems like a great answer. Not sure why my question got two down votes. Seems like a straight forward question with a straightforward answer. Thanks for your help. – Jeff Sep 01 '14 at 14:24
  • Hi, Ram, I have to wait ten more minutes before I can accept it. – Jeff Sep 01 '14 at 14:25
  • 1
    @Jeff it is a straightforwarded question. And that's why it's downvoted. There are questions regarding this subject already – Déjà vu Sep 01 '14 at 14:25
  • @Jeff [Just a quick example](http://stackoverflow.com/questions/1361741/get-characters-after-last-in-url?rq=1) – Déjà vu Sep 01 '14 at 14:26
  • @Déjàvu, if you know anything than it doesn't mean to vote down other. if the question is irrelevant than it's understandable. – Ram Sharma Sep 01 '14 at 14:27
  • @RamSharma I didn't downvote him. I'm just saying that there are other questions like that on this site and people might've downvoted him for that. – Déjà vu Sep 01 '14 at 14:31
  • @RamSharma But if the question "doesn't show any research effort", it's candidate to downvote. If I search "get the last part of a url php" in google, the 3 first results are **exact** duplicates to this question ... – Clément Malet Sep 01 '14 at 14:31
  • In that case put the question on hold or mark it as duplicate that's it. – Ram Sharma Sep 01 '14 at 14:32