可以修改元素。通過循環遍歷數組,可以直接修改數組中的元素值。例如:
$fruits = array("apple", "banana", "cherry"); foreach ($fruits as &$fruit) { $fruit = strtoupper($fruit); } print_r($fruits);
上面的代碼會將數組中的每個元素轉換為大寫字母輸出。