2019鐵人賽
一個陣列元素相當於一個變數。
透過索引(index)來取出。
陣列第一筆的索引是 0,陣列第二筆的索引是 1,陣列最後一筆的索引是 n-1。
<?php
$陣列變數名稱[索引值] = 元素名稱;
?.
<?php
$weeks[] = "Sunday";
$weeks[] = "Monday";
$weeks[] = "Tuesday";
$weeks[] = "Wednesday";
$weeks[] = "Thursday";
$weeks[] = "Friday";
$weeks[] = "Saturday";
foreach ($weeks as $week) {
echo $week . "\n";
}
?>
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
reference from http://php.net/manual/en/language.types.array.php
reference from IBSN 978-986-476-232-3