Alpha index

Discussion in 'PHP' started by Buyer1seller, Aug 7, 2009.

  1. #1
    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
     
    Buyer1seller, Aug 7, 2009 IP
  2. Buyer1seller

    Buyer1seller Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    :( no anyone to help
     
    Buyer1seller, Aug 7, 2009 IP
  3. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #3
    Can you explain a little more what the purpose of this is? Do these need to be links, or just text?
     
    jestep, Aug 7, 2009 IP
  4. Buyer1seller

    Buyer1seller Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I want it for upcoming songs site..

    azindex like wordpress
     
    Buyer1seller, Aug 7, 2009 IP
  5. oop

    oop Peon

    Messages:
    35
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    
    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
     
    oop, Aug 7, 2009 IP
  6. Buyer1seller

    Buyer1seller Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thank you oop

    How can i install this code ?
     
    Buyer1seller, Aug 7, 2009 IP
  7. oop

    oop Peon

    Messages:
    35
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    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 &bull; Playlists</title>
    </head>
    <body>
    <div id="alphaselector"><?=alhpabet()?></div>
    </body>
    </html>
    
    PHP:
     
    oop, Aug 7, 2009 IP
  8. Buyer1seller

    Buyer1seller Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    WOW thanks buddy u really help me lots :):):D

    Thanks again
     
    Buyer1seller, Aug 7, 2009 IP
  9. oop

    oop Peon

    Messages:
    35
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    your welcome dood
     
    oop, Aug 7, 2009 IP