Skip to content

Instantly share code, notes, and snippets.

@MubinSayed
Created October 2, 2018 05:21
Show Gist options
  • Save MubinSayed/0baf92c31705274cecd2a87a0b1e05e9 to your computer and use it in GitHub Desktop.
Save MubinSayed/0baf92c31705274cecd2a87a0b1e05e9 to your computer and use it in GitHub Desktop.
<?php
$colors = array("0"=>"Red","1"=>"Green","2"=>"Blue");
echo "0th element of array is " . $colors["0"];
echo "<br>";
//looping
foreach ($colors as $key=>$value){
echo "Key=".$key." value=".$value;
echo "<br>";
}
?>
<?php
$foo = array(
1 => "Value1",
2 => "Value2",
10 => "Value10"
);
while($bar = each($foo)){
echo $bar[0] . " => " . $bar[1];
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment