Array creation, initializing
'老大','2'=>'老三','1'=>'老二');
if( isset($arr3) ) {print_r($arr3);}
?>
Using the value of an array
Print data for a group
//直接通过index访问
"我",'love'=>'爱','u'=>'你');
if(isset($arr))
{
foreach($arr as $key=>$value)
{
echo $value.' ';
}
}
?>
Summarize
PHP arrays are divided into indexed array associative arrays
Associative array is an array of key values that are strings
For example, examples of foreach in the previous example.
"我",
'love'=>'爱',
'li'=>'莉'
);
if(isset($arr))
{
foreach($arr as $key=>$value)
{
print_r($value);
//echo $value;
}
}
?>
Associative array creation, initializing
'苹果');
$arr = array();
$arr['apple'] = '苹果';
if( isset($arr) ) {print_r($arr);}
?>
Associative array references (using the name of the array variable followed by the brackets + keys to access the values in the array, the keys are enclosed in single or double quotes.) )
"苹果",'banana'=>"香蕉",'pineapple'=>"菠萝"
);
$arr0 = $arr['apple'];
if( isset($arr0) ) {print_r($arr0);}
?>