Skip to content

Instantly share code, notes, and snippets.

@AlexPashley
Last active September 5, 2021 07:35
Show Gist options
  • Save AlexPashley/5861144 to your computer and use it in GitHub Desktop.
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 ...
<?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();
@Prakashpaarthipan
Copy link

`<?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 ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment