Skip to content

Instantly share code, notes, and snippets.

@niravmadariya
Created June 7, 2018 07:49
Show Gist options
  • Save niravmadariya/ef0bc83efcdf841bd5d4f0efeb93bb06 to your computer and use it in GitHub Desktop.
Save niravmadariya/ef0bc83efcdf841bd5d4f0efeb93bb06 to your computer and use it in GitHub Desktop.
Numerical and Associative Array Example in php
<?php
$a[0] = 1; // Numeric Array
$a[1] = 2;
$a[2] = 3;
$a[3] = 4;
$a[4] = 5;
$b['a']='a'; // Associative Array
$b['b']='b';
$b['c']='c';
$b['d']='d';
$b['e']='e';
foreach($a as $aa){
echo $aa;
}
foreach($b as $key => $value){
echo $key." : ".$value;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment