By I Wayan Simpen 16 October 2008
1
Array Multi Dimensi Bentuk: Variabel=array( [key1 =>] array ([key11=>]value1, [key12=>]value2,……), [key2 =>] array ([key21=>]value1, [key22=>]value2,……), );
...
16 October 2008
2
Contoh: Array Multi Dimensi • Buatlah web page untuk meng-input belanja seorang pelanggan dg: ¾ Data masukkan: Nama Buah, Kualitas, dan Jumlah/kg ¾ Output: Total Harga
DAFTAR HARGA BUAH/KG Kualitas Buah 1 2 3 Jeruk 15,000 12,500 10,000 Apel 20,000 15,000 13,000 Mangga 18,000 14,000 11,000 16 October 2008
3
Layout Input:
16 October 2008
4
html>
Array array(15000,12500,10000), "Apel" => array(20000,15000,13000), "Mangga" => array(18000,14000,11000)); 16 October 2008
5
print("
"); print("DAFTAR HARGA BUAH/KG | "); print("Buah | Kualitas |
"); print("1 | 2 | 3 |
"); 16 October 2008
6
//tampilkan isi tabel while (list($index1,$nilai1)=each($Harga)) { print(""); print($index1); print(" | "); while (list($index2,$nilai2)=each($nilai1)) { print("");print($nilai2);print(" | "); } print("
"); } print("
"); ?> 16 October 2008
7
PEMBELIAN
16 October 2008
9
",$total); } ?>