我想从字符串中获取子字符串: 解释这个的最好方法是使用以下示例:
$string = 'locations?city=London';
if (strpos($string,'city=') !== false)
{
// now here I need something to get London in a string
}
答案 0 :(得分:5)
parse_str( parse_url( 'locations?city=London', PHP_URL_QUERY ), $params );
print_r( $params );
// outputs: Array ( [city] => London )
echo $params['city'];
// outputs London