Home > Article > Backend Development > php-Arrays function-array_fill-fills an array with a given value_PHP tutorial
array_fill() function fills an array with the given value
【Function】
This function will return a new array,
The array is filled with the specified amount of the specified content.
【Scope of use】
php4 > 4.2.0, php5.
【Use】
array array_fill( int start_index, int num, mixed value )
start_index/required/the starting number of key names in the new array
num/Required/ is the number of items to be filled in the new array. This value must be a value greater than zero, otherwise php will issue a warning
value/required/is the value in the new array
【Example】
[php]
print_r( array_fill( 5, 6, "hehe" ) );
/*
Array
(
[5] => hehe
[6] => hehe
[7] => hehe
[8] => hehe
[9] => hehe
[10] => hehe
)
*/
Excerpted from zuodefeng’s notes