• 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

Last order would be re-order in wooCommerce. How is it possible?

How to break out of a foreach once a condition is met?

how to loop through json response data using ajax jquery?

IlluminateDatabaseQueryException: SQLSTATE[HY000]: General error: 1 no such table - In clone project

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

laravel 5.6 bulk inserting json data

If action is on a different page do I use fwrite function

How can I make Laravel return a custom error for a JSON REST API

how to identify the web server name of remote host

How to get values inside <![CDATA[values]] > using php DOM?

How to read laravel_session cookies saved in cookie memory of browser in client side?

How to get median and quartiles/percentiles of an array in JavaScript (or PHP)?

Edit XML in HTML form and submit to self

PHP Discord OAUTH2 code sample not working

Check If array is null or not in php

About Contact Privacy policy Terms and conditions