<?php
$arr = array('name' => 'Linwebs', 'city' => 'Chiayi', 'school' => 'ncyu');
print_r($arr);
$arr2 = array(
array('name' => '蘋果', 'price' => 100),
array('name' => '香蕉', 'price' => 20.5),
array('name' => '芭樂', 'price' => 40.25)
);
print_r($arr2);
echo '<table>';
echo '<tr>' . '<th>id</th>' . '<th>名稱</th>' . '<th>價格</th>' . '</tr >';
foreach ($arr2 as $key => $item) {
echo '<tr>';
echo '<td>' . $key . '</td>';
echo '<td>' . $item['name'] . '</td>';
echo '<td>' . $item['price'] . '</td>';
echo '</tr>';
}
echo '<tr>' . '<td colspan="3">總共有 ' . count($arr2) . ' 種水果</td>' . '</tr>';
echo '</table>';
?>