Loop through Alphabet with PHP


/ Published in: PHP
Save to your folder(s)

Loops through ASCII characters to display alphabet, useful for alphabetic filtering links.

eg: A | B | C | D ...


Copy this code and paste it in your HTML
  1. // Loop through ASCII characters until reaching 90
  2. for ($i=65; $i<=90; $i++) {
  3.  
  4. // store the character
  5. $letter = chr($i);
  6.  
  7. // build alphabetical link
  8. $alphabet .= '<a title="filter results by letter '.$letter.'" href="/business/'.$letter.'"> ';
  9. $alphabet .= $letter;
  10. $alphabet .= '</a> | ';
  11. }
  12.  
  13. // print links
  14. echo $alphabet;

URL: http://www.apashley.co.uk/snippets/38/Loop-Through-The-Alphabet-With-Php.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.