Menus & Navigation
|
|
|
|
<?php
// Build letter link function
// function & build_link(&$word)
{
static $prev_letter;
// Extract the first letter
$first_letter = substr($word,0,1);
// Build a link for this letter if this letter wasn't extracted before,
//
if($prev_letter != $first_letter)
{
$prev_letter = $first_letter;
// Modify the url to your needs
//
return ' [<a href="letter_'.$prev_letter.'.htm">'.strtoupper($prev_letter).'</a>] ';
}
else
{
return false;
}
}
// The word list array.
// $word_list = array(
'affect',
'courtesy',
'cult',
'despair',
'feudal',
'file',
'analogy',
'mass',
'delay',
'patrol');
// Sort the word list. This is necessairy to get unique links
// sort($word_list);
// Build letters links of the word list
// foreach($word_list as $word)
{
$link = build_link($word);
if($link)
{
echo $link;
}
} ?>
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|