function getTextGeneric($foobar, $whichvar) { echo gettype($foobar); //returns the string "array" if (array_key_exists($whichvar, $foobar)) { //I get Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object [.....code here.....] } else { [....error code here......] }