相关疑难解决方法(0)

为什么带有null作为回调的array_map()会创建一个"数组数组"?

今天我学习了array_map()PHP的一个特例,在文档中作为旁注提到:

Example#4创建一个数组数组

<?php
$a = array(1, 2, 3, 4, 5);
$b = array("one", "two", "three", "four", "five");
$c = array("uno", "dos", "tres", "cuatro", "cinco");

$d = array_map(null, $a, $b, $c);
print_r($d);
?>
Run Code Online (Sandbox Code Playgroud)

上面的例子将输出:

Array
(
    [0] => Array
        (
            [0] => 1
            [1] => one
            [2] => uno
        )

    [1] => Array
        (
            [0] => 2
            [1] => two
            [2] => dos
        )

    [2] => Array
        (
            [0] => 3
            [1] => three
            [2] => tres
        )

    [3] …
Run Code Online (Sandbox Code Playgroud)

php arrays specifications array-map

7
推荐指数
1
解决办法
1439
查看次数

标签 统计

array-map ×1

arrays ×1

php ×1

specifications ×1