php数组函数序列之array_combine() - 数组合并函数使用说明_PHP教程

WBOY
Release: 2016-07-21 15:23:20
Original
1025 people have browsed it

array_combine() 定义和用法
array_combine() 函数通过合并两个数组来创建一个新数组,其中的一个数组是键名,另一个数组的值为键值。

如果其中一个数组为空,或者两个数组的元素个数不同,则该函数返回 false。

语法
array_combine(array1,array2)
参数 描述
array1 必需。规定键名。
array2 必需。规定值。

提示和注释
注释:两个参数必须有相同数目的元素。

例子

复制代码代码如下:

$a1=array("a","b","c","d");
$a2=array("Cat","Dog","Horse","Cow");
print_r(array_combine($a1,$a2));
?>

输出:

Array ( [a] => Cat [b] => Dog [c] => Horse [d] => Cow )

www.bkjia.com true http://www.bkjia.com/PHPjc/324483.html TechArticle array_combine() 定义和用法 array_combine() 函数通过合并两个数组来创建一个新数组,其中的一个数组是键名,另一个数组的值为键值。 如果其中...
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!