array_fill(): Filling an array with values

Fills an array with given value.
$new_array = array_fill ($start_key, $number, $value);
ParameterDESCRIPTION
$start_keyRequired : Integer , starting key number.
$numberRequired: Integer: Number of elements filled.
$valueRequired: value to be used to fill the array.
Returns an array with $number of $values as elements starting from key $start_key.

Example 1

$result=array_fill(2,4,'plus2net');
while (list ($key, $val) = each ($result)) {
echo "$key -> $val 
"; }
Output is here.
2 -> plus2net 
3 -> plus2net 
4 -> plus2net 
5 -> plus2net

Example 2 with negative $start_key

$result=array_fill(-3,4,'plus2net');
while (list ($key, $val) = each ($result)) {
echo "$key -> $val <br>";
}
Output
-3 -> plus2net 
0 -> plus2net 
1 -> plus2net 
2 -> plus2net 


plus2net.com




Post your comments , suggestion , error , requirements etc here .




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer