Print out array keys only

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • undbund

    Print out array keys only

    Hi, there are lots of examples that show you how to print array values
    given a key. Do you know how to print keys for a given array.

    example

    $myArray = array('a'=>1, 'b'=>2, 'c'=>3, 'd'=>4);

    How do you print 'a', 'b', 'c','d' only without using any loops?

    Thanks in advance for all your help
    Undbund

  • Rami Elomaa

    #2
    Re: Print out array keys only

    undbund kirjoitti:
    Hi, there are lots of examples that show you how to print array values
    given a key. Do you know how to print keys for a given array.
    >
    example
    >
    $myArray = array('a'=>1, 'b'=>2, 'c'=>3, 'd'=>4);
    >
    How do you print 'a', 'b', 'c','d' only without using any loops?
    >
    Thanks in advance for all your help
    Undbund
    >
    echo implode(', ', array_keys($myA rray));

    --
    Rami.Elomaa@gma il.com

    "Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
    usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze

    Comment

    Working...