You will need to create many similar variables in the process of using PHP for development, either early or late.
Without a lot of similar variables, you can store the data in an array as an element.
Elements in the array have their own IDs, so they can be easily accessed.
There are three types of arrays:
Array of values
An array with a numeric ID key
Example
$names = Array ("Peter", "Quagmire", "Joe");
echo $names [1]. "and". $names [2]. "Is". $names [0]. "' s Neighbors";
The output of the above code:
Quagmire and Joe are Peter ' s neighbors
Associative arrays
Each ID key in the array associates a value
$ages = Array ("Peter" =>32, "quagmire" =>30, "Joe" =>34);
echo "Peter is". $ages [' Peter ']. "Years old.";
Output from the above script:
Peter is the years old.
Multidimensional arrays
An array that contains one or more arrays
$families = array
(
"Griffin" =>array
(
"Peter",
"Lois",
"Megan"
),
"Quagmire" =>array
(
"Glenn"
),
"Brown" =>array
(
"Cleveland",
"Loretta",
"Junior"
)
);
If you output this array, it should look something like this:
Array
(
[Griffin] = = Array
(
[0] = Peter
[1] = Lois
[2] = Megan
)
[Quagmire] = = Array
(
[0] = Glenn
)
[Brown] = Array
(
[0] = Cleveland
[1] = Loretta
[2] = Junior
)
)
http://www.bkjia.com/PHPjc/822520.html www.bkjia.com true http://www.bkjia.com/PHPjc/822520.html techarticle you will need to create many similar variables in the process of using PHP for development, either early or late. Without a lot of similar variables, you can store the data in an array as an element. ...