Reputation: 141
I'm looking to get a Substring from a String: The best way to explain this is with following example:
$string = 'locations?city=London';
if (strpos($string,'city=') !== false)
{
// now here I need something to get London in a string
}
Upvotes: 1
Views: 403
Reputation: 1858
parse_str( parse_url( 'locations?city=London', PHP_URL_QUERY ), $params );
print_r( $params );
// outputs: Array ( [city] => London )
echo $params['city'];
// outputs London
Upvotes: 5