PHP HTML Dynamic List From Array
From w3cyberlearnings
Contents |
PHP Dynamic HTML List from Array
Makes Order or Un-order List from array.
Example 1: Make from a normal array
- Un-order List
<?php $actors = array( 'Greta Garbo', 'Andy Garcia', 'Ava Gardner', 'Lucy Johnson' ); echo '<ul>'; foreach ($actors as $actor) { echo '<li>'; echo $actor; echo '</li>'; } echo '</ul>'; ?>
Output: HTML Source
<ul> <li>Greta Garbo</li> <li>Andy Garcia</li> <li>Ava Gardner</li> <li>Lucy Johnson</li> </ul>
Example 2
- Order List
<?php $actors = array( 'Greta Garbo', 'Andy Garcia', 'Ava Gardner', 'Lucy Johnson' ); echo '<ol>'; foreach ($actors as $actor) { echo '<li>'; echo $actor; echo '</li>'; } echo '</ol>'; ?>
Related Links
Dynamic HTML From Array
- Dynamic Drop Down List with Array
- Dynamic List with Array
- Dynamic Radio with Array
- Dynamic Checkbox with Array
Dynamic HTML From Database
Dynamic HTML with Ajax
Others Related