PHP arrays
PHP arrays introductionArrays are used for storing one or more values in a single variable name. Each element of an array has its own ID for easy access. Arrays can be of the following types:
Numeric: An array with numeric ID key
Example:$names = array(“Mike”, “Perry”);
Above array can be interpreted as :- array[0]= mike and array[1]= perry
Associative: An array in which each ID key is associated with a value.
Example:$ages = array("mike"=>32, "perry"=>30);
Multidimensional: Having more than one array
Example:$families = array
(
"lawson"=<array
(
"Peter",
"Lois",
"Megan"
),
"james"=<array
(
"Glenn"
)
);
Explain the purpose of $GLOBALS superglobal array with an example.
$GLOBAL array contains all the global variables used in the script. The variable names are the keys of the array.