Last active
September 5, 2021 07:35
-
-
Save AlexPashley/5861144 to your computer and use it in GitHub Desktop.
PHP: Loops through ASCII characters to display alphabet, useful for alphabetic filtering links. eg: A | B | C | D ...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_alphabet() | |
{ | |
$alphabet = ''; | |
// Loop through ASCII characters until reaching 90 | |
for ($i=65; $i<=90; $i++) { | |
// store the character | |
$letter = chr($i); | |
// build alphabetical link | |
$alphabet .= '<a title="filter results by letter '.$letter.'" href="/business/'.$letter.'"> '; | |
$alphabet .= $letter; | |
$alphabet .= '</a> | '; | |
} | |
return $alphabet; | |
} | |
// print links | |
echo get_alphabet(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
`<?php
function d(){
for($i="\v";$i<"o";$i++){
echo ord($i)-ord("\n")."\t";
}
}
d();
?>`
I have tried above code for ascii char's iterate in for loop. for print 1 - 100 decimal value. But i can not get it. Can you help ..