Before looping through a variable (supposed to be an array) I would make the following test:
if(
!empty($arrJobs) &&
is_array($arrJobs) &&
count($arrJobs)
){
foreach ($arrJobs as $item) {
//loop tasks
}
}
I've seen also using if(sizeof($arrJobs)>0) but in case $arrJobs isa integer (I can't trust the input) it would be through and I will try looping through a integer...weird.
Is there a more concise and comprehensive way to perform this test before looping through the array?