喜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函數存在一些錯誤,但我找不到它。
檢查你更換後得到什麼真正的價值。您最好將替換結果存儲在另一個變量中。 –