• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Why does array_map() with null as callback create an "array of arrays"?

phparraysspecificationsarray-map


PHP Snippet 1:

$d = array_map('array', $a, $b, $c);

PHP Snippet 2:

$array = [
    [1 => 'one', 2 => 'two', 3 => 'three']
];
var_export(array_map(fn() => func_get_args(), ...$array));
echo "\n---\n";
var_export(array_map(null, ...$array));

PHP Snippet 3:

array (
  1 => 
  array (
    0 => 'one',
  ),
  2 => 
  array (
    0 => 'two',
  ),
  3 => 
  array (
    0 => 'three',
  ),
)
---
array (
  1 => 'one',
  2 => 'two',
  3 => 'three',
)

Related Snippets

Xdebug in Laravel is not working with VSCode

Laravel 5 controller sending JSON integer as string

Why is this PHP array not the same?

Problems getting instance of UploadedFile in Yii2

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource [duplicate]

Elasticsearch - Want to sort by field in all indices where that particular field available or not if not then avoid it

How to generate QR CODE for dynamic generating link and logo using Simple QrCode in laravel?

WooCommerce Additional Information - if empty, hide

laravel automatically deletes server.php on php artisan serve

Cut an arabic string

str_replace or preg_replace random number from string

Get all WooCommerce products within own plugin

XAMPP keeps showing Dashboard/Welcome Page instead of the Configuration Page

Using spatie/media-library, how to rename a collection of uploaded files?

Target Laravelista is not instantiable

About Contact Privacy policy Terms and conditions