Array & empty

I am using the cakephp framework.
So I do that code to see if this user had machines

$cu= 
 $this->Customer->find('first', 
array('conditions' => array('CUSTOMER_ID'=>$id)));
  and this
  if (!empty($cu['machine']))

and it worked in place of

count($cu['machine'])

It were strange to me why did not worked the count.
Why?

What is the type of $cu[‘machine’]? Use var_dump() to see. type NULL, maybe?

I haven’t explored this issue in-depth. But I try to use empty() when I need th check if there is something in array. Because count and sizeof may give 1 while it is not array at all!
and empty() gives the same result as count($arr) > 0 && is_array($arr), but it requires twice less code :slight_smile:

first var_dump($cu)
if(is_array($cu)) {

}else{

}