Best way to use an array that is returned from a function immediately in PHP
So, .. you want to simply check whether a certain key in an array is set to a certain value.

You can't do this directly on the function call because older PHP versions don't support array dereferencing. You are right when saying you'll need an intermediate variable.

The only question remaining is what to name it. Considering that the variable will probably be situated in a really small scope, don't worry about it too much. There is a saying which says, the bigger the scope, the bigger the name. You could just name it $list.

Old replies:


  Your code does something else as what
  you describe? If you want to see
  whether a given value is present in
  the array, use in_array().
  
  UPDATE:
  
  I believe I understand what you are
  trying to accomplish now. You just
  want to see whether the key is set?
  
  array_key_exists()
  
  PHP has got a pretty good online API,
  be sure to check it for existing
  implementations when looking for a
  solution.