How can i remove NULL
values in an array with its index and reassign the index to other values in order?
Array
(
[1] => 115,2010-02-17,19:30
[3] => 400,2006-03-01,22:00
[4] => 474,2006-04-10,02:30
[5] => 7547,2006-08-02,23:16
)
But what i need is:
Array
(
[1] => 115,2010-02-17,19:30
[2] => 400,2006-03-01,22:00
[3] => 474,2006-04-10,02:30
[4] => 7547,2006-08-02,23:16
)
try like this
<?php
$array=array(0=>"a",3=>"b");
$b=array_values($array);
print_r($b);
//displays Array ( [0] => a [1] => b )
?>
More info array_values
$new = array_values($array_with_holes);
PS: actually there are no NULL
values in your array, it's just an array with sparse keys
$array1=Array();
//here assign array value to $linksArray
foreach ($array1as $key => $link)
{
if ($array1[$key] == '')
{
unset($array1[$key]);
}
}