Arrays in PHP
Posted under » PHP on 13 March 2009
To me arrays are like a variable that can hold more than one value at a time, an inline databases if you will.
I won't go to nested arrays where it gets confusing but lets start with associative arrays. An associative array uses index keys but these keys are not numeric as the example shown below.
define array
$camera = array (
"canon" => array("pro" => "1D", "full frame" => "5D", "prosumer" => "50D"),
"nikon" => array("pro" => "D3", "full frame" => "D700", "prosumer" => "D90"),
);
// Echo this out:
print_r($camera);
If you just want to show Canon Prosumer camera model which is 50D
echo $camera["canon"]["prosumer"];
