我有随机的产品链接网址。
我想要结果Like>
http://yourdomain.com/index.php?main_page=product_info&products_id=5 产品编号= 5 要么 http://yourdomain.com/index.php?main_page=product_info&products_id=3210:cdfa96a858cdde666a79b09207528297 产品编号= 3210
先谢谢
答案 0 :(得分:2)
$string = "http://yourdomain.com/index.php?main_page=product_info&products_id=5";
$pattern = "/products_id=(\d+)/";
preg_match($pattern, $string, $matches);
$out = "Product Id = ".$matches[1];