• 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

Store / Website Column in Magento 2 Admin Grid - Custom Module

Querying only one row from a one to many relationship laravel

Elastic Beanstalk with Laravel Envoy

CodeIgniter force_download is not working

PHP: Calling MySQL Stored Procedure with Both INPUT AND OUTPUT Parameters (NOT "INOUT")

wordpress : How to specify the cause "This site can’t be reached"

Laravel excel maatwebsite 3.1 import, date column in excel cell returns as unknown format number. How to solve this?

Send POST data via raw JSON with Postman

How to get variable from JavaScript to PHP [duplicate]

Get sum of arrays inside array

I want to use codeigniter foreign character library in my custom PHP project how i can use it?

php retrieve specific data onclick from database in a list format

How to convert a carbon into string, to take the date only?

Redirect to previous page with php

Laravel Unknown Column 'updated_at'

About Contact Privacy policy Terms and conditions