|
<?php
$array = array("key1" => "Simon", 2 => "Elaine"); //數(shù)組的創(chuàng)建
echo $array["key1"]; //輸出Simon
echo $array[2]; //輸出Elaine
?>
復(fù)制代碼 代碼如下:
<?php
$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
?>
復(fù)制代碼 代碼如下:
<?php
$array = array("key1" => array(0 => 1, 1 => 10, 2 => 100), //定義數(shù)組
"key2" => array(0 => 5, 1 => 25, 2 => 125));
print_r($array); //輸出數(shù)組
?>
復(fù)制代碼 代碼如下:
<?php
$array = array("a", "b","c"); //定義數(shù)組
print_r($array); //輸出數(shù)組
?>
復(fù)制代碼 代碼如下:
<?php
$array = array("a", "b","c"); //定義數(shù)組
$array[0] = "Simon"; //修改數(shù)組元素
print_r($array); //輸出數(shù)組
?>
php技術(shù):php 數(shù)組的創(chuàng)建、調(diào)用和更新實(shí)現(xiàn)代碼,轉(zhuǎn)載需保留來(lái)源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。