Jump to content

echo and lists


KillerWolf

Recommended Posts

[code]
<?php
$data = array ('Dog', 'Cat', 'Bird', 'Fish');

echo '<h3>Animals - ordered list</h3>';
echo '<ol>';
foreach ($data as $animal) {
    echo "<li>$animal</li>" ;
}
echo '</ol>';

echo '<h3>Animals - unordered list</h3>';
echo '<ul>';
foreach ($data as $animal) {
    echo "<li>$animal</li>" ;
}
echo '</ul>';

?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/28470-echo-and-lists/#findComment-130276
Share on other sites

try
[code]
<?php
$data = array ('Dog', 'Cat', 'Bird', 'Fish');

// SORTED list
sort ($data);

echo '<h3>Animals - sorted list</h3>';
echo '<ul>';
foreach ($data as $animal) {
    echo "<li>$animal</li>" ;
}
echo '</ul>';


// RANDOM list
shuffle ($data);

echo '<h3>Animals - random list</h3>';
echo '<ul>';
foreach ($data as $animal) {
    echo "<li>$animal</li>" ;
}
echo '</ul>';

?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/28470-echo-and-lists/#findComment-131240
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.