Copy code The code is as follows:
$array = array("key1" => "Simon", 2 => "Elaine"); //Creation of array
echo $ array["key1"]; //Output Simon
echo $array[2]; //Output Elaine
?>
Copy code The code is as follows:
$array = array("key1" => array(0 => 1, 1 => 10, 2 => 100),
"key2" => array(0 => 5, 1 => 25 , 2 => 125));
echo $array["key1"][0]; //Output 1
echo $array["key1"][1]; //Output 10
echo $array["key1 "][2]; //Output 100
echo $array["key2"][0]; //Output 5
echo $array["key2"][1]; //Output 25
echo $array[" key2"][2]; //Output 125
?> => 1, 1 => 10, 2 => 100), //Define the array
"key2" => array(0 => 5, 1 => 25, 2 => 125)) ;
Copy code
The code is as follows:
$array = array("a", "b", "c"); //Define array
print_r($array); //Output array
Copy code
The code is as follows:
$array = array( "a", "b","c"); //Define array
$array[0] = "Simon"; //Modify array elements
The above introduces the creation, calling and updating implementation code of the ideal idiom PHP array, including the content of realizing the ideal idiom. I hope it will be helpful to friends who are interested in PHP tutorials.