The Dark Knight's Tutorials Part I - Looping Through A PHP Array
Hey there, this is a very simple tutorial mainly for beginner PHP coders. This is the first of what I hope will become a very long series of tutorials.
Difficulty: Easy
Coding Time: 10 Minutes
Extensions: None
Overview
This tutorial loops through an array of hyperlinks and outputs them in an unordered list.
hyperlink.php
PHP Code:
<?php
$array['Link One Caption'] = "page.html";
$array['Link Two Caption'] = "page2.html";
$array['Link Three Caption'] = "page3.html";
echo("<ul>");
foreach($array as $caption=>$link) {
echo("<li><a href='$link'>$caption</a></li>");
};
echo("</ul>");
This code will produce something like the following...
Last edited by knightcon; 03-11-2008 at 06:07 PM.
Reason: Show what the tutorial code will output
~The Dark Knight
This city deserves a better class of criminal