An empty array in PHP is considered falsey. That means the following will not print anything as the array is empty.
<?php
$myArray = array()
if ( $myArray ) {
print "My Array is NOT empty";
}
What is considered better practice in this case when determining if there are elements in the array:
- To use
if ( !empty( $myArray ) )
- To use
if ( myArray )
Please note: this question is not about subjectivity. I don't care what my team mate thinks. I care about best practices in the industry.