Page 1 of 1

Need help checking if an array is empty

Posted: Sat Feb 13, 2010 12:19 pm
by someguyhere
Here is what I'm trying:

Code: Select all

if (isset($related_keywords)) {
$related_list = ul($related_keywords);
}
(obviously $related_keywords is the array)

Since it is set, this doesn't work, even though the elements in the array are empty. Can someone point me in the right direction?

Re: Need help checking if an array is empty

Posted: Sat Feb 13, 2010 12:31 pm
by Darhazer
try with

Code: Select all

if (!emtpy($related_keywords))

Re: Need help checking if an array is empty

Posted: Sat Feb 13, 2010 1:44 pm
by someguyhere
No dice. How about this...what should I change here?

Code: Select all

if (empty($related_keywords))
    $related_list = NULL;
else
$related_list = "<h3>Related keywords</h3>".ul($related_keywords);

Re: Need help checking if an array is empty

Posted: Sat Feb 13, 2010 1:49 pm
by someguyhere
Solved it:

Code: Select all

if (empty($related_keywords[0]))
    $related_list = NULL;
else
$related_list = "<h3>Related keywords</h3>".ul($related_keywords);