converting letters to words , i am sure this is simple

Discussion in 'PHP' started by mnymkr, Jun 25, 2007.

  1. #1
    I have some GET variables coming in that I need to change to words

    If $_GET = e I need it to say BIG

    if $_GET = f i need it to say Yellow


    is there a simple concise way to write this function?
     
    mnymkr, Jun 25, 2007 IP
  2. UnrealEd

    UnrealEd Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you don't really need a function to do this, you can just use an array with the letters as key, and the words as value:
    $words = array ( 'e' => 'BIG', 'f' => 'Yellow' );
    if ( array_key_exists ( $_GET['myvar'], $words ) ) {
      echo $words[ $_GET['myvar'] ];
    }
    PHP:
     
    UnrealEd, Jun 25, 2007 IP
  3. mnymkr

    mnymkr Well-Known Member

    Messages:
    2,328
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    120
    #3
    you are all over the boards. thanks to you i understand array's alot better.

    thanks again....what is this the 20th time now. LOL
     
    mnymkr, Jun 25, 2007 IP
  4. UnrealEd

    UnrealEd Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    anytime man, i'm glad i could help :)
     
    UnrealEd, Jun 25, 2007 IP
  5. dp-user-1

    dp-user-1 Well-Known Member

    Messages:
    794
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #5
    Arrays are incredibly useful. Most people don't realize all they can do.
     
    dp-user-1, Jun 25, 2007 IP