Ordered list from an array in PHP


Quick snippets of code that will help you to create an ordered list from a php array :

Here’s the array :

<?php $array=array(“Android 4.1.2 Operating System”,”Dual Core Qualcomm Snapdragon S4 processor”,”Qualcomm Adreno 203 2D/3D Graphics Core”); ?>

Here’s what we process it with :

<ul>
<?php
$count = 0;
foreach ($array as $item) {
echo ‘<li>’ ;
echo $item;
echo ‘</li>’;
$count ++;
}
?>
</ul>

And here’s the output :

  • Android 4.1.2 Operating System
  • Dual Core Qualcomm Snapdragon S4 processor
  • Qualcomm Adreno 203 2D/3D Graphics Core