php 数组的创建、调用和更新实现代码_PHP

WBOY
Release: 2016-06-01 12:23:35
Original
802 people have browsed it
复制代码 代码如下:
$array = array("key1" => "Simon", 2 => "Elaine"); //数组的创建
echo $array["key1"]; //输出Simon
echo $array[2]; //输出Elaine
?>


复制代码 代码如下:
$array = array("key1" => array(0 => 1, 1 => 10, 2 => 100),
"key2" => array(0 => 5, 1 => 25, 2 => 125));
echo $array["key1"][0]; //输出1
echo $array["key1"][1]; //输出10
echo $array["key1"][2]; //输出100
echo $array["key2"][0]; //输出5
echo $array["key2"][1]; //输出25
echo $array["key2"][2]; //输出125
?>


复制代码 代码如下:
$array = array("key1" => array(0 => 1, 1 => 10, 2 => 100), //定义数组
"key2" => array(0 => 5, 1 => 25, 2 => 125));
print_r($array); //输出数组
?>


复制代码 代码如下:
$array = array("a", "b","c"); //定义数组
print_r($array); //输出数组
?>


复制代码 代码如下:
$array = array("a", "b","c"); //定义数组
$array[0] = "Simon"; //修改数组元素
print_r($array); //输出数组
?>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!