To Remove An Empty Element From An Array Using PHP
Guys in the below code i am explaining how you can find out the
empty array…and create a new array by deleting the empy ones
dynamically.
In the variable data array i have given 8 datas
let $a, $b, $c, $d,$e contains data and others that is $f, $g, $h are empty so we will get the new array size as 5 by using the
sizeof() in PHP.
$data=array(“$a”, “$b”, “$c”, “$d”, “$e” , “$f” ,”$g” , “$h”);
//print_r($data);
function array_trim($data)
{
$j = 0;
for ($i = 0; $i < count($data); $i++)
{ if ($data[$i] != “”)
{ $b[$j++] = $data[$i];
}
}
return $b;
}
$new_size=array_trim($data);
Related posts:

good..