<?php
$present = array('長崎' => 'ちゃんぽん', '名古屋' => '手羽先', '沖縄' => '泡盛', );
print $present['長崎']. '<br>';
print $present['名古屋'] . "<br>";
print $present['沖縄']. '<br>';
<?php
$sales = array('日' =>10 , '月' =>20 , '火' => 30, '水' => 40, '木' => 50, '金' => 60, '土' => 70, );
print '火金の合計は' . ($sales['火'] + $sales['金']) . 'です。';
<?php
$price = array ('4' => '100円', '1' => '1000円', '2' => '20円', '3' => '50円', );
$code = array_search('20円', $price);
print '20円のキーは' . $code .'です。';
<?php
$city = array('東京', '名古屋', '京都', '大阪', '福岡');
?>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>配列を使う</title>
</head>
<body>
<table border="2" width="120">
<tr><th>番号</th><th>都市名</th></tr>
<?php
foreach ($city as $id => $value) {
print '<tr><td>' . $id .'</td><td>' .$value .'</td></tr>' ."\n";
}
?>
</table>
</body>
</html>