轉換這個PHP腳本爲Javascript:如何創建字符串數組(使用字符串鍵)?
$ar = array();
// add dynamically new element to string array
$ar['aaa'] = "Hello";
$ar['bbb'] = "World";
$ar['ccc'] = "Test!";
foreach($ar as $key => $val){
print $key." => ".$val."\n";
}
結果將是:
aaa => Hello
bbb => World
ccc => Test!
謝謝!
(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects) –