Blogger Information
Blog 12
fans 0
comment 0
visits 6619
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
array数组第一课-php学习第x课
虎哥的学习日志
Original
563 people have browsed it

创建数组

$arrName=array(

key1=>value1,

key2=>value2,

key3=>value3,

...

);

php 5.4以后,引入新[ ]取代了array();

$arrName=[

key1=>value1,

key2=>value2,

key3=>value3,

...

]

数组可以用[]或{}访问,如$arrName['key1'] 或$arrName{'key1'}

删除数组成员 unset($arr['age']);//删除age

unset($arr);//删除数组

删除数组中的成员,但保留数组结构

foreach($arr as $key=>$value){

unset($arr[$key]);

}

$arr=[

0=>10,1=>20,2=>30

];

unset($arr[1]);

$newarr=array_values($arr);//重建数组索引

输出数组

echo 

print_r();

var_dump();

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post