喜IM要去尝试x,y位置添加到我的静态谷歌地图图像位置的字符串,是str_replace函数无法正常工作
$googlemapstatic="http://maps.googleapis.com/maps/api/staticmap?center=(location)&zoom=7&size=1000x1000&markers=color%3ablue|label%3aS|11211&sensor=false&markers=size:mid|color:0x000000|label:1|(location)";
,我必须为它的纬度和经度x和y
$koorX='32.323213123';
$koorY='39.3213';
和即时通讯使用str替换改变静态地图的位置和标记在里面。
$newlocation=$koorX.','.$koorY;
$googlemapstatic=str_replace('location',$newlocation,$googlemapstatic);
但它显示了与输入不同的位置。
<img style='width:15.61cm; height:12.0cm' src=".$googlemapstatic.'>
如果我从浏览器手动编写x,y,它会显示正确的位置。 我认为str_replace函数存在一些错误,但我找不到它。
检查你更换后得到什么真正的价值。您最好将替换结果存储在另一个变量中。 –