2012-05-05 52 views
1

我希望得到一個字符串的子串後得到一個字符串的子字符串: 最好的辦法來解釋這與下面的例子:如何一個特定的單詞

$string = 'locations?city=London'; 
if (strpos($string,'city=') !== false) 
{ 
    // now here I need something to get London in a string 
} 
+3

開始['parse_url'](http://php.net/parse_url)。 – hakre

回答

5
parse_str(parse_url('locations?city=London', PHP_URL_QUERY), $params); 

print_r($params); 

// outputs: Array ([city] => London) 

echo $params['city']; 

// outputs London 
+0

是的,這就是我一直在尋找:) – milepile

相關問題