How to extract coordinates from Google Maps link (PHP or Javascript) -


i have google map link looks this:

https://www.google.com/maps/place/space+needle/@47.620506,-122.349277,17z/data=!4m6!1m3!3m2!1s0x5490151f4ed5b7f9:0xdb2ba8689ed0920d!2sspace+needle!3m1!1s0x5490151f4ed5b7f9:0xdb2ba8689ed0920d

how can extract coordinates in php or javascript array:

{47.620506, -122.349277} 

if you're not using api (which isn't advisable), put page string, , extract long/lat within ... it's given multiple times on page parameter ll ... i'm not regex, i'll give example using strstr

<?php     $url='https://www.google.com/maps/place/space+needle/@47.620506,-122.349277,17z/data=!4m6!1m3!3m2!1s0x5490151f4ed5b7f9:0xdb2ba8689ed0920d!2sspace+needle!3m1!1s0x5490151f4ed5b7f9:0xdb2ba8689ed0920d';     $result=file_get_contents($url);     $ll=explode(',',substr(strstr(strstr($result,'?ll='),'&',true),4));     $long=$ll[0];     $lat=$ll[1]; ?>