Home  >  Article  >  php教程  >  array_file_keys:使用指定的键和值填充数组

array_file_keys:使用指定的键和值填充数组

PHP中文网
PHP中文网Original
2016-05-23 16:40:021237browse

array_file_keys(array $keys,$values)
使用$keys 作为键值,$values 作为值

$arr_keys = ['aa','bb'];
$values = ['11','22',33];

$arr = array_fill_keys($arr_keys,$values);

echo '';
print_r($arr);

result:
Array
(
    [aa] => Array
        (
            [0] => 11
            [1] => 22
            [2] => 33
        )

    [bb] => Array
        (
            [0] => 11
            [1] => 22
            [2] => 33
        )

)		            		        	
			
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn