Answers for "get empty values from array in php"

PHP
11

php array remove empty values

<?php
$arr = array('1', '', '2', '3', '0');
// Incorrect:
print_r(array_filter($arr));
// Correct:
print_r(array_filter($arr, 'strlen'));
//Custom
print_r(array_filter($arr, function ($val) {if ($val > 0) {return true;} else {return false;}}));
Posted by: Guest on July-07-2020
2

array should not be empty php

$arr = array();

if(!empty($arr)){
  echo "not empty";
}
else 
{
  echo "empty";
}
Posted by: Guest on August-10-2020

Code answers related to "get empty values from array in php"

Browse Popular Code Answers by Language