Meaning of the code

Discussion in 'PHP' started by rrn, May 3, 2009.

  1. #1
    if (!is_array($menu))
    		return false;
    PHP:
    somebody pls explain the meaning of the above line of code . what it actually does?
     
    rrn, May 3, 2009 IP
  2. wwwbryan

    wwwbryan Well-Known Member

    Messages:
    181
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    #2
    If $menu is not in the array then do nothing.
     
    wwwbryan, May 3, 2009 IP
  3. exodus

    exodus Well-Known Member

    Messages:
    1,900
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    165
    #3
    looks like it should be in a function. Basically, ! means not. is_array returns true if the variable is an array of variables. So, basically if the variable is not an array then return false as the value and again it should be in a function so the var return for the function would be false if the gave var is not an array.
     
    exodus, May 3, 2009 IP
  4. Steve136

    Steve136 Peon

    Messages:
    240
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hey,

    exodus is right. It checks to see if the $menu variable is an array or not.

    There are other similar functions, the best place to get answers from is http://uk.php.net/manual/en/function.is-array.php (and the rest of PHP.net) everything is documented.

    Regards,

    Steve
     
    Steve136, May 3, 2009 IP
  5. creativeGenius

    creativeGenius Well-Known Member

    Messages:
    273
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    120
    #5
    literally it checks if the variable $menu is not array, and returns false if it's true
     
    creativeGenius, May 3, 2009 IP
  6. rrn

    rrn Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks to all those who gave solutions.. i understood the meaning..

    thank you......
     
    rrn, May 3, 2009 IP