2020年3月23日
<?php
$arr1['name']='数组1';
var_dump($arr1);
echo"<hr>";
$arr2 = array(
'name' => 'tim',
'age' => 18,
'like' => 'game',
);
var_dump($arr2);
echo"<hr>";
$arr3 = [
'name' => 'tim',
'age' =>18,
'like' => 'game',
];
var_dump($arr3);
echo"<hr>";
$arr4 = [
'tim',
18,
];
var_dump($arr4);
echo "<hr>";
$arr5 = [
'name'=> 'tim',
'number' => '12580',
];
var_dump($arr5);
echo"<hr>";
$arr6 = [
'name' => 'tim',
'like' => ['game',
'sleep',
'girl',
'play' =>[
'football',
]
]
];
var_dump($a);
$arr2 =[
10,
20,
30,
40,
50 => 666,
];
var_dump($arr2);
echo"<br>";
unset($arr2[2]);
var_dump($arr2);
echo"<br>";
$arr2=array_values($arr2);
var_dump($arr2);
$arr1 = [
'name' => 'tim',
'like' => 'game',
'like' => 'ball',
];
var_dump($arr1);
echo"<br>";
$arr1['like']= '篮球';
var_dump($arr1);
echo"<hr>";
$arr2 =[
10,
20,
30,
40,
50 => 666,
];
var_dump($arr2);
echo"<br>";
unset($arr2[2]);
var_dump($arr2);
echo"<br>";
$arr2=array_values($arr2);
var_dump($arr2);
php2
<?php
$arr1['name']='数组1';
var_dump($arr1);
echo"<hr>";
$arr2 = array(
'name' => 'tim',
'age' => 18,
'like' => 'game',
);
var_dump($arr2);
echo"<hr>";
$arr3 = [
'name' => 'tim',
'age' =>18,
'like' => 'game',
];
var_dump($arr3);
echo"<hr>";
$arr4 = [
'tim',
18,
];
var_dump($arr4);
echo "<hr>";
$arr5 = [
'name'=> 'tim',
'number' => '12580',
];
var_dump($arr5);
echo"<hr>";
$arr6 = [
'name' => 'tim',
'like' => ['game',
'sleep',
'girl',
'play' =>[
'football',
]
]
];
var_dump($a);
$arr2 =[
10,
20,
30,
40,
50 => 666,
];
var_dump($arr2);
echo"<br>";
unset($arr2[2]);
var_dump($arr2);
echo"<br>";
$arr2=array_values($arr2);
var_dump($arr2);
$arr1 = [
'name' => 'tim',
'like' => 'game',
'like' => 'ball',
];
var_dump($arr1);
echo"<br>";
$arr1['like']= '篮球';
var_dump($arr1);
echo"<hr>";
$arr2 =[
10,
20,
30,
40,
50 => 666,
];
var_dump($arr2);
echo"<br>";
unset($arr2[2]);
var_dump($arr2);
echo"<br>";
$arr2=array_values($arr2);
var_dump($arr2);
php3
<?php
$arr1['name']='数组1';
var_dump($arr1);
echo"<hr>";
$arr2 = array(
'name' => 'tim',
'age' => 18,
'like' => 'game',
);
var_dump($arr2);
echo"<hr>";
$arr3 = [
'name' => 'tim',
'age' =>18,
'like' => 'game',
];
var_dump($arr3);
echo"<hr>";
$arr4 = [
'tim',
18,
];
var_dump($arr4);
echo "<hr>";
$arr5 = [
'name'=> 'tim',
'number' => '12580',
];
var_dump($arr5);
echo"<hr>";
$arr6 = [
'name' => 'tim',
'like' => ['game',
'sleep',
'girl',
'play' =>[
'football',
]
]
];
var_dump($a);
$arr2 =[
10,
20,
30,
40,
50 => 666,
];
var_dump($arr2);
echo"<br>";
unset($arr2[2]);
var_dump($arr2);
echo"<br>";
$arr2=array_values($arr2);
var_dump($arr2);
$arr1 = [
'name' => 'tim',
'like' => 'game',
'like' => 'ball',
];
var_dump($arr1);
echo"<br>";
$arr1['like']= '篮球';
var_dump($arr1);
echo"<hr>";
$arr2 =[
10,
20,
30,
40,
50 => 666,
];
var_dump($arr2);
echo"<br>";
unset($arr2[2]);
var_dump($arr2);
echo"<br>";
$arr2=array_values($arr2);
var_dump($arr2);
笔记:
数组的定义
数据类型的时候,有一个类型叫array;
$arr = array();
定义方式:
直接赋值的方式来声明数组
使用array()语言结构创建一个空数组
使用【】也可以创建一个新数组
多维数组的声明方式
key:索引值
value:内容
直接赋值的方式:$变量名【key】=value
直接给一个不存在的变量进行数组赋值,会自动的创建;
只有在每个数据之间加上逗号,就可以写多个值
多维数组就是嵌套的层数很多3层或过3层
删除关联数组:unset()
数组内容可以重复,key不能重复,一个key只能对应一个值;