Is their any easy method for getting array value in php?

Discussion in 'PHP' started by aruna_r, Mar 15, 2011.

  1. #1
    Is their any easy method for getting array value in php instead of this.,
    <?
    a=array("A","B","C");
    ?>
     
    aruna_r, Mar 15, 2011 IP
  2. spaceman12

    spaceman12 Active Member

    Messages:
    60
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    63
    #2
    what do u mean by the easy way?
     
    spaceman12, Mar 15, 2011 IP
  3. joy1986joy

    joy1986joy Member

    Messages:
    189
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    #3
    try to use mysql_fetch_array() for array fetch.
     
    joy1986joy, Mar 15, 2011 IP
  4. Automagick

    Automagick Greenhorn

    Messages:
    22
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    23
    #4
    No there is not.

    In Javascript, you could do easier with JSON, like this: var array=['A','B','C'];

    But in PHP there is not.

    Of course you could use array_fill(), to generate an array easier, but I'm sure that's not what you mean.
     
    Automagick, Mar 17, 2011 IP
  5. lordspace

    lordspace Peon

    Messages:
    38
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    $arr = array();
    $arr[] = "A";$arr[] = "B";

    why would you be looking for a simpler way ?
     
    lordspace, Mar 17, 2011 IP
  6. srisen2

    srisen2 Peon

    Messages:
    359
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    yes there is only the mysql and the regular $arr['a'] nothing simpler exists but there are more complex ways but it would just use uneeded code
     
    srisen2, Mar 18, 2011 IP
  7. lordspace

    lordspace Peon

    Messages:
    38
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    aruna_r maybe you're coming from a different language than PHP/Perl.
    give yourself some time to learn the syntax of the language. I'd say the syntax is the easiest part of any language.
    Learning the methodologies and best practices should be your goal.
     
    lordspace, Mar 19, 2011 IP
  8. buddyborg

    buddyborg Guest

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    parsing an array in php is as easy as it is in any other language. there are multiple ways to do it. the syntax is just different. i would like to help but i don't feel as if i completely understand your question.
     
    buddyborg, Mar 19, 2011 IP