I am trying to insert these $lat and $lng variable into the final $html variable with no success. Can somebody point me in the right direction?..
Much Appreciated.
<?php
$lat = '33.599968';
$lng = '-112.119499';
$url = 'http://maps.google.com/maps/api/staticmap? center=$lat,$lng&zoom=13&size=665x400&markers=color:red|$lat,$lng&sensor=false';
$html = '<img border="0" src="$url" width="665" height="400" border="1"></a>';
echo $lat;
echo $lng;
echo $url;
echo $html;
?>
two changes in the url line:
$url = "http://maps.google.com/maps/api/staticmap?center=$lat,$lng&zoom=13&size=665x400&markers=color:red|$lat,$lng&sensor=false";
" instead of ' so that php will evaluate $lat,$lng
And you want remove the space before center:
... staticmap? center ...
becomes
... staticmap?center ...
Strings delimited with double quotes "
interpolate variables, strings delimited with single quotes '
do not. Use "
.