Blogger Information
Blog 250
fans 3
comment 0
visits 321781
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
数组:直接赋值法
梁凯达的博客
Original
2146 people have browsed it

直接赋值法,是指数组直接赋值到变量当中,用var_dump()打印数组类型;

数组类型分为:

1/索引数组

2/关键数组

3/混合数组

4/多维度数组

------

//直接赋值法声明数组

//1.索引数组

$arr[] = 1;

$arr[] = '深圳我琦哥';

$arr[] = '女';

$arr[] = '';

var_dump($arr);

//直接赋值如果声明的时候不指定下标,默认从0开始分配索引下标


$arr1[2]=1;

$arr1[10]='广州大哥';

$arr1[]='潮汕达哥';

$arr1[3]='';

var_dump($arr1);

//如果给出索引下标  下一个下标就会从最大的开始每次增加1

//如果后面出现前面的下标,就会覆盖前面的值

//2 关键数组

$arr2['姓名']='潮汕梁大叔';

$arr2['学历']='本科没有';

$arr2['身高']=172;

$arr2['收入']=1000;

$arr2['工作年限']=3;

$arr2['头发']='长发';

var_dump($arr2);


//混合数组

$arr3['1']='潮汕梁大叔';

$arr3['学历']='本科没有';

$arr3['3']=172;

$arr3['收入']=1000;

$arr3['5']=3;

$arr3['头发']='长发';

var_dump($arr3);


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