This option will reset the home page of this site. Restoring any closed widgets or categories.

Reset

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);

VN:F [1.5.7_846]
Rating: 0.0/10 (0 votes cast)
VN:F [1.5.7_846]
Rating: 0 (from 0 votes)

Related posts:

  1. Get Method and Array Manipulation In Symfony
  2. XML Parsing Made Easy

1 Comment

  1. samarubanok says:

    good..

    VA:F [1.5.7_846]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.5.7_846]
    Rating: 0 (from 0 votes)

Leave a Reply

Comments (required)

Spam Protected