• 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

how to make my own auto increment in php?

Coinpayments create_transaction "ERROR: Invalid command!"

Laravel You requested 1 items, but there are only 0 items available

How to check user Permissions using Custom Middleware in Laravel

Issue saving card for customer

PHP if in_array() how to get the key as well?

How do I get friend list from Friends table with counts of friends of my friends

Composer Warning: openssl extension is missing. How to enable in WAMP

Combine array with same value and add other [duplicate]

Converting array to string and then back in PHP

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

Laravel after login Two factor not working

codeigniter 4 running error first time with xampp

How to fix Call to undefined method AppModelsTableName::factory?

How to validate tin and cst using PHP?

About Contact Privacy policy Terms and conditions