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

前端之家收集整理的这篇文章主要介绍了php 数组的创建、调用和更新实现代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

<div class="codetitle"><a style="CURSOR: pointer" data="1133" class="copybut" id="copybut1133" onclick="doCopy('code1133')"> 代码如下:

<div class="codebody" id="code1133">
<?PHP
$array = array("key1" => "Simon",2 => "Elaine"); //数组的创建
echo $array["key1"]; //输出Simon
echo $array[2]; //输出Elaine
?>
<div class="codetitle"><a style="CURSOR: pointer" data="92847" class="copybut" id="copybut92847" onclick="doCopy('code92847')"> 代码如下:
<div class="codebody" id="code92847">
<?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
?>
<div class="codetitle"><a style="CURSOR: pointer" data="70821" class="copybut" id="copybut70821" onclick="doCopy('code70821')"> 代码如下:
<div class="codebody" id="code70821">
<?PHP
$array = array("key1" => array(0 => 1,//定义数组
"key2" => array(0 => 5,2 => 125));
print_r($array); //输出数组
?>
<div class="codetitle"><a style="CURSOR: pointer" data="10342" class="copybut" id="copybut10342" onclick="doCopy('code10342')"> 代码如下:
<div class="codebody" id="code10342">
<?PHP
$array = array("a","b","c"); //定义数组
print_r($array); //输出数组
?>
<div class="codetitle"><a style="CURSOR: pointer" data="91779" class="copybut" id="copybut91779" onclick="doCopy('code91779')"> 代码如下:<div class="codebody" id="code91779">
<?PHP
$array = array("a","c"); //定义数组
$array[0] = "Simon"; //修改数组元素
print_r($array); //输出数组
?>

php创建数组数组数组数组更新更新更新调用调用调用

猜你在找的PHP相关文章