How do I check that a PHP array is not empty?
// If $columns array is not empty...
foreach ($columns as $column) {
echo $column;
}
One way is to use count()
if (count($columns) > 0) {
foreach ($columns as $column) {
echo $column;
}
}
if($array). count would be bad for large arrays, however empty is a good solution as well.