<?php
$num=array(1,2,3,4,5,6,7,8,9,10);
echo '<b>array before grow elements :</b>';
foreach($num as $num1)
{
echo ' '.$num1;
}
echo '<br><br>';
$num = array_pad($num, 20,'a') ; //only additionally adding elements have 'a' value
// $num = array_pad($num, 20,'') ; additionally adding elements have empty
echo '<b>array after grow elements :</b>';
foreach($num as $num1)
{
echo ' '.$num1;
}
?>
output :
array before grow elements : 1 2 3 4 5 6 7 8 9 10
array after grow elements : 1 2 3 4 5 6 7 8 9 10 a a a a a a a a a a
note :
1) just modify " $num = array_pad($num, 20,'a') ; " as " $num = array_pad($num, 20,'') ; " for empty
2) that means array index raise but with empty values
$num=array(1,2,3,4,5,6,7,8,9,10);
echo '<b>array before grow elements :</b>';
foreach($num as $num1)
{
echo ' '.$num1;
}
echo '<br><br>';
$num = array_pad($num, 20,'a') ; //only additionally adding elements have 'a' value
// $num = array_pad($num, 20,'') ; additionally adding elements have empty
echo '<b>array after grow elements :</b>';
foreach($num as $num1)
{
echo ' '.$num1;
}
?>
output :
array before grow elements : 1 2 3 4 5 6 7 8 9 10
array after grow elements : 1 2 3 4 5 6 7 8 9 10 a a a a a a a a a a
note :
1) just modify " $num = array_pad($num, 20,'a') ; " as " $num = array_pad($num, 20,'') ; " for empty
2) that means array index raise but with empty values