Home > Backend Development > PHP Tutorial > PHP学习札记 02

PHP学习札记 02

WBOY
Release: 2016-06-13 13:18:26
Original
782 people have browsed it

PHP学习笔记 02
数组

1.创建数组:
$users = array("a","b");
改变数组的值 $users[0] = "c";

for($i=1;$i   $users[$i];
}
统计数组个数 count()

foreach($users as $key=>$value){
   echo $value;
}

创建自定义key的数组

$test = array{"key"=>"value"}
访问数据 $test["key"]


追加数组
$test["new"] = "test";

list($a,$b) 将数组的数据,复制到$a。list只能识别下标位数字的数组。自定义字符串key是无法识别的。

rest() 将数组指针指向第一个单元

array_unique 移除重复的值
array_flip 交换数组的键和值


二维数组:
$array = array(array(...))
一个数组可以包含多个不同类型的变量




print_r()打印易于理解的信息

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