0

I need extract item id from url's like these (number after last slash)

http://codecanyon.net/item/test item/12219820
                                   //^^^^^^^^
http://codecanyon.net/item/another item/75219586
                                      //^^^^^^^^
http://codecanyon.net/item/item contain number v1.2/74419586
                                                  //^^^^^^^^

Some items has digits in name. How i can extract just id at end of links with regular expression in php?

Rizier123
  • 57,440
  • 16
  • 89
  • 140
user2511140
  • 1,560
  • 2
  • 25
  • 31

1 Answers1

4

This should work for you:

(Just take the last part of the url (string) with basename())

echo basename($url);
Rizier123
  • 57,440
  • 16
  • 89
  • 140