• 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

I cannot create a auto generated date time in mysql workbench

SQL AVG() to 2 decimals

PHP drop down list using array's and foreach (else and for) code

How to get array values using foreach in laravel

Symfony Mercure "Failed to send an update"

how to retrieve the first and last instance of a row in pdo dataset

Change user role if checkout custom checkbox is checked in WooCommerce

Add restriction to WooCommerce coupons by allowed user ID

Undefined Array Key error when uploading image on php

How to get quarter for future date using Carbon?

Getting output of MS stored procedure on php call

Sum column values from multiple arrays

Laravel 5 issue with wherePivot

PHPUnit (Phar) Fatal Error Only When Test Fails

PHP using str_starts_with for array to exclude same as with wildcard

About Contact Privacy policy Terms and conditions