[note] javascript 的 foreach / split / php explode style 寫法

var loc=”25.258861, 121.509389″; var arr=loc.split(“,”); var content = ”; for (var key in arr) { content += key + ‘ : ‘ + arr[key] + “\n”; } 另一個 var myarr = new Array(‘red’,’green’,’blue’); var content=”; for(var key in myarr){ content += key+’ : ‘+myarr[key]+”\n”; } alert( content );