标签:created value bin ons phpstorm function cti pos code
(PHP 5, PHP 7)
array_combine — 创建一个数组,用一个数组的值作为其键名,另一个数组的值作为其值
$keys , array $values ) : array返回一个 array,用来自 keys 数组的值作为键名,来自 values 数组的值作为相应的值。
返回合并的 array,如果两个数组的单元数不同则返回 FALSE。
<?php /** * Created by PhpStorm. * User: mac * Date: 2019/4/13 * Time: 10:10 */ $arr1 = [‘a‘,‘b‘,‘c‘]; $arr2 = [1,2,3,4]; $res = array_combine($arr1,$arr2); echo "<pre>"; print_r($res); //
上面返回 Warning: array_combine(): Both parameters should have an equal number of elements in /www/wang/functions/combine.php on line 12
参数不一致
$arr1 = [‘a‘,‘b‘,‘c‘]; $arr2 = [1,2,3]; $res = array_combine($arr1,$arr2); echo "<pre>"; print_r($res);
上面返回
Array
(
[a] => 1
[b] => 2
[c] => 3
)
$arr1 = [‘a‘,‘b‘,‘c‘]; $arr2 = [1,2,3]; $res = array_combine($arr2,$arr1); echo "<pre>"; print_r($res);
上面返回
Array
(
[1] => a
[2] => b
[3] => c
)
标签:created value bin ons phpstorm function cti pos code
原文地址:https://www.cnblogs.com/php-linux/p/10700037.html