Hi Php geeks, How can create alpha php index like eg; #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 Thanks
function alphabet(){ //Start an array with the first element as the bash sybol $a2z = array('#'); //loop threw an alphabetical for and then breaking when hits double alphas for($a = 'a'; $a != 'aa'; $a++){$a2z[] = $a;} //imploding the array with a seperator return implode(" | ",$a2z); } PHP: USAGE: <?=alphabet()?> PHP: RESULTS: # | 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 Code (markup): LINK VERSION <?php function alphabet(){ //Start an array with the first element as the bash sybol $a2z = array('#'); //loop threw an alphabetical for and then breaking when hits double alphas for($a = 'a'; $a != 'aa'; $a++){ $a2z[] = sprintf('<a href="index.php?letter=%s" title="%s">%s</a>',$a,$a,$a); } //imploding the array with a seperator return implode(" | ",$a2z); } ?> PHP: Peace
as long as that function is within the include scope you can use it any where so lets so i have this file structure includes: -- functions.php images: -- image1.png -- etcetc.png index.php Code (markup): and i put the function i told you into functions.php as long as i include the functuions file into my index i can use it so heres my index.php <?php include 'includes/functions.php'; /*I can now use the functions i saved into the functions file as it is now incorperated into my index by the include*/ ?> <html> <head> <title>Home • Playlists</title> </head> <body> <div id="alphaselector"><?=alhpabet()?></div> </body> </html> PHP: