Mega Code Archive

 
Categories / Php / Statement
 

Displaying the contents of an array using a loop

<?php $shapes = array('S' => 'Cylinder',                 'N' => 'Rectangle',                 'A' => 'Sphere',                 'O' => 'Sphere',                 'P' => 'Rectangle'); foreach ($shapes as $key => $value) {     print "The $key is a $value.<br />"; } ?>