RE: [PHP] stepping through alphabet
| From: | Steve Buehler | Date: | Wed, 19 Nov 2003 14:39:32 +0000 |
| Subject: | RE: [PHP] stepping through alphabet | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-170291@lists.php.net to get a copy of this message | ||
I was hoping for something that looked (at least to me) a little cleaner. Someone else gave me the answer and here is my final code that works out just great for me.
for($letter = 'A', $i = 0; $i <= 25; $letter++, $i++ ){
echo "<a href=\"?action=alphabet&letter=$letter\">$letter</a> ";
}
Amazing what I learned today. :) I love this list and its people.
Thanks for your help
Steve
At 08:15 AM 11/19/2003, you wrote:
Create a $letters array and the loop through it like this: $letters=array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'); foreach($letters as $letter) {echo "<a href=\"?action=alphabet&letter=$letter\">$letter</a>\n";} Luis -----Original Message----- From: Steve Buehler [<mailto:steve@ibapp.com>mailto:steve@ibapp.com] Sent: Wednesday, November 19, 2003 8:03 AM To: PHP Subject: [PHP] stepping through alphabet I am using PHP 4.3.4 and am trying to come up with a function that will step through the alphabet so that I get a menu/links that can be clicked on like below: <a href="?action=alphabet&letter=A">A</a> <a href="?action=alphabet&letter=B">B</a> <a href="?action=alphabet&letter=C">C</a> etc........... I am sure that this has been done and is probably pretty easy. Any help here would be appreciated. I know that I could just create a link for each letter, but I would like to learn to do this so that I can make code shorter. Putting each letter into an array and steping through the array will work, but can it be done by telling a loop to start at A and end at Z? Thanks Steve -- PHP General Mailing List (<http://www.php.net/>http://www.php.net/) To unsubscribe, visit: <http://www.php.net/unsub.php>http://www.php.net/unsub.php