I’m building an array to determine if I need to take an action. I am executing a query. The table has a sent_date field to determine if an email has been sent to a user or not. Once it has been sent to a user, that sent_date field is populated with getdate(). Here is how I’m building:
$sent_date_sql = "
select ind_id, sent_date from profileemail
";
$results = dbExec($sent_date_sql);
I then build my array:
foreach ($results as $r){
array_push($sent_date,$r['sent_date']);
$query_count = count($results);
}
This all is working gloriously. My issue is when I go to check the sent_date array. The first time in the month that this script runs, ALL sent_date values are NULL. So my array looks like:
array(228) {
[0]=>
NULL
[1]=>
NULL
[2]=>
NULL
[3]=>
NULL
[4]=>
NULL
…etc.
Now I am going to try to evaluate $sent_date:
if(empty($sent_date)){
My empty condition never hits because the values of the array are all NULL. Is there an alternative way to achieve what I am trying to do? Should I be looping through my $sent_date array and evaluating each value?
array_filterremoves all “empty” elements from the array. If all elements in the array are “empty”, the result is an array with no elements (array()). An empty array evaluates tofalse.