Jump to content

[SOLVED] Array with all values NULL, but "empty" does not work


lopes_andre

Recommended Posts

Hi,

 

I'am a novice programmer. And I'am with some dificulties in this code...

 

if (!empty($c_pesquisa)) {
            	if (empty($aCategoria)) {
            		$query_ = $query_ . " c_anuncio like '%{$c_pesquisa}%'";
            	} else {
            	$query_ = $query_ . " AND c_anuncio like '%{$c_pesquisa}%'"; 		
            	}
            }

 

The variable $aCategoria is an array, the values inside the array are all "null" in my debug but the code jumps to "$query_ = $query_ . " AND c_anuncio like '%{$c_pesquisa}%'";" instead of "$query_ = $query_ . " c_anuncio like '%{$c_pesquisa}%'";"

 

What I'am doing wrong?

 

 

Best Regards, André.

If an array contains any values it will not be empty, whether the values are null, "", or what ever.  (array() is considered empty.)

 

 

You will either have to unset() null key/val pairs, or you will have to make a function that looks for a value in an array that is not null.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.