lopes_andre Posted March 8, 2009 Share Posted March 8, 2009 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é. Link to comment https://forums.phpfreaks.com/topic/148500-solved-array-with-all-values-null-but-empty-does-not-work/ Share on other sites More sharing options...
corbin Posted March 8, 2009 Share Posted March 8, 2009 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. Link to comment https://forums.phpfreaks.com/topic/148500-solved-array-with-all-values-null-but-empty-does-not-work/#findComment-779795 Share on other sites More sharing options...
lopes_andre Posted March 8, 2009 Author Share Posted March 8, 2009 Thanks a lot! I will find a solution. Best Regards, André. Link to comment https://forums.phpfreaks.com/topic/148500-solved-array-with-all-values-null-but-empty-does-not-work/#findComment-779807 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.