Modify PHP Array Values: Quick Guide

To change the value of a one-dimensional array in PHP, you can use the array keys to access and modify the elements in the array. Here is an example:

<?php
// 创建一个一维数组
$array = array('a' => 1, 'b' => 2, 'c' => 3);

// 修改数组中的值
$array['b'] = 5;

// 打印修改后的数组
print_r($array);
?>

In the example above, we first create a one-dimensional array containing three elements. We then use the key ‘b’ to access and modify the corresponding value in the array, changing the original 2 to 5. Finally, we print out the modified array.

bannerAds