这篇文章主要为大家详细介绍了php 数组操作(增加,删除,查询,排序)等函数的简单示例,具有一定的参考价值,可以用来参考一下。
感兴趣的小伙伴,下面一起跟随四海网的小编小韵来看看吧!
数据增加,删除,查询,排序详细说明代码如下:
<?php
$names[0] = "Peter";
$names[1] = "Quagmire";
$names[2] = "Joe";
echo $names[1] . " and " . $names[2] . " are ". $names[0] . "'s neighbors";
?>
代码如下:
$ages = array("Peter"=>32, "Quagmire"=>30, "Joe"=>34);
代码如下:
$ages['Peter'] = "32";
$ages['Quagmire'] = "30";
$ages['Joe'] = "34";
代码如下:
<?php
$ages['Peter'] = "32";
$ages['Quagmire'] = "30";
$ages['Joe'] = "34";
echo "Peter is " . $ages['Peter'] . " years old.";
?>
代码如下:
$families = array
(
"Griffin"=>array
(
"Peter",
"Lois",
"Megan"
),
"Quagmire"=>array
(
"Glenn"
),
"Brown"=>array
(
"Cleveland",
"Loretta",
"Junior"
)
);
代码如下:
Array
(
[Griffin] => Array
(
[0] => Peter
[1] => Lois
[2] => Megan
)
[Quagmire] => Array
(
[0] => Glenn
)
[Brown] => Array
(
[0] => Cleveland
[1] => Loretta
[2] => Junior
)
)
代码如下:
$arr1 = array('aaa', 'bbb');
$arr2 = array('a'=>'AAA', 'b'=>'BBB');
代码如下:
$arr[0] = 'aaa';
$arr[1] = 'bbb';
foreach($arr as $v){
echo $v;
}
代码如下:
$arr = array('a'=>'AAA', 'b'=>'BBB');
$arr[] = 'CCC';
代码如下:
$arr = array('a'=>'AAA', 0=>'BBB');
foreach($arr as $a){
echo $a;
}
代码如下:
$arr['a'] = 'AAA';
$arr['b'] = 'BBB';
echo "array[a] is $arr[a]";
本文来自:http://www.q1010.com/173/13563-0.html
注:关于php 数组操作(增加,删除,查询,排序)等函数的简单示例的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。
关键词:
四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。