• 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

How in Laravel run JavaScript code stored in php variable?

Laravel 5.1 Unknown database type enum requested

Laravel Passport - Not able to get token string in response?

Timber: Single post pagination does not work (wp_link_pages)

SMTP ERROR: MAIL FROM command failed: 530 5.7.0 Must issue a STARTTLS command first when using PHPMailer

How to Make Laravel Eloquent "IN" Query?

"cannot list resources" error from WooCommerce REST API

PHP Slim Framework request using withAttribute error

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

Require a class from another class - php

Laravel whole batch is cancelled if one Job fails

Search for array row with specific column value and return another value from qualifying row

CONCAT columns with Laravel 5 eloquent

getting error while enter Command => php artisan route:list

Laravel query builder binding parameters more than once

About Contact Privacy policy Terms and conditions