you can try a for () from the lowest index to the highest and full if it is empty
for($i = 0 ;$i <= 8 ; $i++)
{
//if it not set
if(!isset($array[$i]))
{
//set to empty
$array[$i] = "";
}
}
Alternatively, you can first count the number of elements in the array and wrap it in a function
function completeIndexes($array)
{
$total = count($array);
for($i = 0 ;$i < $total ; $i++)
{
if(!isset($array[$i]))
{
$array[$i] = "";
}
}
return $array;
}
source
share