I used to check if an array has values like below:
$array = array('John', 'Peter', 'Bill', 'Andrew');
if($array != NULL) {
echo 'Array contains values';
}
else {
echo 'Array is empty';
}
According to php 7.2 about NULL, it says: This feature has been DEPRECATED as of PHP 7.2.0. Relying on this feature is highly discouraged.
So what's the best alternative in this situation to check if an array has some values?
if( !empty($array) ) {
or
if( $array != '' ) {
or ???