• 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

How to make a array inside array?

phparrays


PHP Snippet 1:

$data['fileToUpload'] = array_map(
  function($item) {
    return [$item];
  },
  $data['fileToUpload']
);

PHP Snippet 2:

 $myArray = [];
 $myArray['fileToUpload']['name'] = array("file name");
 $myArray['fileToUpload']['type'] = array("file type");
 $myArray['fileToUpload']['tmp_name'] = array("temporary name");
 $myArray['fileToUpload']['error'] = array("error");
 $myArray['fileToUpload']['size'] = array("file size");

 echo "<pre>";
 print_r($myArray);

Related Snippets

Sync Records With Default Values in Pivot Tables, Call to undefined method syncWithPivotDefaults()

Why does array_map() with null as callback create an "array of arrays"?

SlimExceptionHttpNotFoundException

XAMPP keeps showing Dashboard/Welcome Page instead of the Configuration Page

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource [duplicate]

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

WHM Enabling mod_rewrite

Updating and Synchronizing Woocommerce Subscriptions to Custom Date

How to run or debug php on Visual Studio Code (VSCode)

Getting error: CodeIgniterDatabaseBaseResult::getResult in CodeIgniter

Only on Firefox "Loading failed for the <script> with source"

How to get an Array value inside an object in an array Php [duplicate]

Why isn't my PHP exception working?

How to get transaction details in notify_url page in paypal

PHP: Print caught exception like Xdebug

About Contact Privacy policy Terms and conditions