• 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 properly start Laravel 8 with Bootstrap & authentication

Laravel Nova, route not found

Laravel: Why is my variable not being set while it's in the construct function of the controller?

Convert string to lowercase AND then convert it to its original form in PHP, is it possible?

PHP random string generator

PHP Startup: Unable to load dynamic library 'openssl' in Ubuntu

How to identify whether webp image is static or animated?

Laravel Jetsream Profile page not loading on fresh install

How to properly set "0000-00-00 00:00:00" as a DateTime in PHP

How to install LDAP in Docker php-fpm alpine

Doctrine ORM: Excluding Records Based on Values of Nested Relationships

PHP's array_map including keys

Reload parent page after submit in iframe

How to use PHPCBF to fix one issue at a time?

Malformed MIME header error in Symfony 5.3

About Contact Privacy policy Terms and conditions