18. PHP Array Functions-5 | array_fill , array_fill_keys, array_filter | ATIBlog

Pubblicato il: 04 dicembre 2017
sul canale di: ATIBlog
341
7

Array functions -5

array_fill ( int $start_index, int $num, mixed $value )
array_fill_keys ( array $keys, mixed $value )
array_filter ( array $input , callback $callback )

1. array_fill()
This function is used to fill a new array with some values at an specified position.
You can fill many same values as you need.
You can say, it creates a new array with a different starting index (not default) and fills the same value.
First parameter is the starting index from where you want to fill.
Second parameter is the number of times the value will be inserted.
Third parameter is the value, which needs to be filled. It can be of any data type.

2. array_fill_keys()
Same like array_fill() . But you need to pass the keys as an array, where the value will be inserted.
Also, it creates an entirely new array with different keys and same value.
First parameter is an array containing the keys.
Second parameter is the value, which will be filled at an specified key position.
The value can have any data type.

3. array_filter()
This function filters the input array as per the user defined function.
It internally iterates each item of the array and pass it to the user defined function.
First parameter is the input array.
Second parameter is the callback function/ user-defined function.


In questa pagina del sito puoi guardare il video online 18. PHP Array Functions-5 | array_fill , array_fill_keys, array_filter | ATIBlog della durata di ore minuti seconda in buona qualità , che l'utente ha caricato ATIBlog 04 dicembre 2017, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 341 volte e gli è piaciuto 7 spettatori. Buona visione!