Php array fill keys
From w3cyberlearnings
Contents |
PHP function array_fill_keys
This function returns a new array fill with values.
Syntax array_fill_keys
- array: array key
- value: value to fill
array_fill_keys(array, value);
Note
Priod to PHP 5 >= 5.2.0 only. You can use another array function to complete the same thing.
Example 1
<?php $person = array('bob', 'janny', 'marry'); $new_person = array_fill_keys($person, "person"); print_r($new_person); ?>
Output
Array ( [bob] => person [janny] => person [marry] => person )
Related Links
- array_change_key_case
- array_chunk
- array_combine
- array_count_values
- array_diff_assoc
- array_diff_key
- array_diff_uassoc
- array_diff_ukey
- array_diff
- array_fill_keys
- array_fill
- array_filter
- array_flip
- array_intersect_assoc
- array_intersect_key
- array_intersect_uassoc
- array_intersect_ukey
- array_intersect
- array_key_ exists
- array_keys