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.
如何使用 php 从 url 中获取特定值?
$orginal=http://wwww.flickr.com/photos/username/1125323/in/photostream/lightbox/";
我想要这个网址的 1125323 吗?
使用以下代码:
<?php $orginal="http://wwww.flickr.com/photos/username/1125323/in/photostream/lightbox/"; $url_data = explode("/",$orginal); $id = $url_data[5]; ?>
使用.*?(\d+)->\1作为正则表达式。
.*?(\d+)
\1
$out = preg_replace('/.*?(\d+)/','$1', $url);
提示:如果您想再次执行此操作,请使用Txt2re 。