如何获取 url 字符串的最后一部分?

How do I get the last part of an url string?

我需要从 url 中提取项目 ID(最后一个斜杠后的数字)

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

有些项目的名称中包含数字。 我如何在 php?

中使用正则表达式在链接末尾提取 id

这应该适合你:

(只取 url(字符串)的最后一部分 basename()

echo basename($url);