Home > Backend Development > PHP Tutorial > PHP array creation, calling and updating implementation code_PHP tutorial

PHP array creation, calling and updating implementation code_PHP tutorial

WBOY
Release: 2016-07-21 15:47:20
Original
789 people have browsed it

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
?>


Copy code The code is as follows:

$array = array("key1" => array(0 => 1, 1 => 10, 2 => 100), //Define array
"key2" => array(0 => 5, 1 => 25, 2 => 125));
print_r($array); //Output array
?>


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
print_r($array ); //Output array
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319944.htmlTechArticleCopy the code as follows: ?php $array = array("key1" = "Simon", 2 = "Elaine "); //Creation of array echo $array["key1"]; //Output Simon echo $array[2]; //Output Elaine? Copy code...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template