Array Key Exists

See all posts Reply

Array Key Exists new!
by Matty, 16 years, 9 months ago
hi there,

two things,....

first i am having a problem with my function http://pastie.caboo.se/106907 i am getting error

PHP Warning: array_key_exists(): The second argument should be either an array or an object in ..../classes/class.upload.php on line 350
PHP Warning: array_key_exists(): The second argument should be either an array or an object in ....classes/class.upload.php on line 353


Anu ideas what this means....

and second......it is possible to tidy my function or am i doing it all okReply
Re: Array Key Exists new!
by colin, 16 years, 9 months ago
Which version of the class are you using? Line 350 is comments, there is no code there.

Can you also output the log of the class, and copy it here?Reply
Re: Array Key Exists new!
by Matty, 16 years, 9 months ago
Ermm...how do i do the log?

Yeah my file is stripped of comments just ot lighten the weight a little

lines 350-353 are:
$this->file_src_mime = (array_key_exists('mime', $info) ? $info['mime'] : NULL); 
// if we don't have a MIME type, we attempt to retrieve it the old way
if (empty($this->file_src_mime)) {
    $mime = (array_key_exists(2, $info) ? $info[2] : NULL);   // 1 = GIF, 2 = JPG, 3 = PNG
Reply
Re: Array Key Exists new!
by colin, 16 years, 9 months ago
To output the log, echo $foo->log after calling $foo->process()

You must have an old version of the class, because from version 0.24 there is a check to make sure that the $info variable is an array:
$this->file_src_mime = (is_array($info) && array_key_exists('mime', $info) ? $info['mime'] : NULL); 
Reply