2014-01-24 83 views

回答

1

試試這個方法:

$content = "https://mysite.com/xyz/jjJAjsjahjsjhUAUiOAkskpAs?q=1280wq"; 

$content = preg_replace("q=\w+", "", $content); 
0
$url = 'https://mysite.com/xyz/jjJAjsjahjsjhUAUiOAkskpAs?q=1280wq'; 

$query = parse_url($url, PHP_URL_QUERY); 
parse_str($query); 

echo $q; 
0

它可以通過str_replace函數就像這樣:

<?php 
$myString = 'https://example.com/xyz/jjJAjsjahjsjhUAUiOAkskpAs?q=1280wq'; 
$myNewString = str_replace('?q=', '/589/', $myString); //this line replaces the '?q=' with '/589/' 
echo $myNewString; //OUTPUT: https://example.com/xyz/jjJAjsjahjsjhUAUiOAkskpAs/589/1280wq 
?>