• 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 to get the total hour from starting time to end time in php

Add New Parameter to Existing URL using htaccess

How to make Canonicals with PHP

Laravel PHP: multiple project run at the same time [closed]

How to auto populate preferredCountries from intl-tel-input with db output

"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP

Respond with status code 401 on authentication failure using Laravel and Passport?

Split comma separated value from table column into rows using mysql?

merge all files in directory to one text file

mysql slow on updates for a well optimized query

Laravel s3 upload file with metadata using pre-signed url

Why does using salted hash on python and php give me different results?

Boolean assignment operators in PHP

Shortcode or PHP inside a shortcode in Wordpress

How can i update or reset my password without entering email field in laravel-8?

About Contact Privacy policy Terms and conditions