Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我一直在试图弄清楚如何获取正则表达式来解析以下网址:
http://localhost/asdf/client/16/admin/64/edit
我想得到的是跟随客户的号码。在这种情况下 16. 我尝试了适用于 的 client/(.+)/ http://localhost/hot_seat/client/16/admin,但是一旦我将 64/edit 添加到 url 中,它就不再起作用了。有任何想法吗?
http://localhost/hot_seat/client/16/admin
尝试这样的事情,因为客户端 ID 是一个整数:
preg_match('/client\/(?P<id>\d+)\/?/', 'http://localhost/asdf/client/16/admin/64/edit', $array); echo $array["id"]; // 16