【发布时间】:2015-01-17 11:54:35
【问题描述】:
我想通过 php 返回 URL 的特定部分。例如,如果 URL 是:
http://website.com/part1/part2/part3/detail/page_id/number/page/2
或
http://website.com/part1/part2/part3/detail/page_id/number/page/3
我要退货号码。
还好吗?
$pattern = "/\d+$/";
$input = "http://website.com/part1/part2/part3/detail/page_id/number/page/2";
preg_match($pattern, $input, $matches);
$post_id = $matches[8];
【问题讨论】:
-
非常感谢@PeterPopelyshko
标签: php