Sunday, February 6, 2011

Sunday 2/6/2011


<?php
//set up a standard array.
$myarray = array("1", "2", "3");
// You can access values from the array as simply as this:
echo $myarray[0]; //would output '1'.
//Or with a for loop
for ($i = 0; $i < count ($myarray); $i++){
echo $myarray[$i] . "
";
}
// setting up an associative array is similarly easy.
$myassocarray = array("mykey" => 'myvalue', "another" => 'one');
//
while ($element = each ($myassocarray)) {
echo "Key - " . $element['key'] . " and Value - " . $element['value'] . "
";
}
?>

No comments: