PHP Replace and Remove? -


i have random product links url.

i want result >

http://yourdomain.com/index.php?main_page=product_info&products_id=5 product id = 5 or http://yourdomain.com/index.php?main_page=product_info&products_id=3210:cdfa96a858cdde666a79b09207528297 product id = 3210

thanks in advance

$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]; 

Comments