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
  • 58,877
  • 16
  • 101
  • 156
user2511140
  • 1,658
  • 3
  • 26
  • 32

1 Answers1

4

This should work for you:

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

echo basename($url);
Rizier123
  • 58,877
  • 16
  • 101
  • 156