• 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

The difference when using if statement true === something() vs something() === true [duplicate]

Combine array with same value and add other [duplicate]

How to change the app environment at run time?

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

WooCommerce: Add/display Product or Variation custom field everywhere

PHP contact form configuration [duplicate]

Any AWS EB Laravel route getting 404 Not Found nginx/1.16.1

Woocommerce product attributes with hierarchy like categories

Issue saving card for customer

Appending data to an anchor tag

calling server using nusoap with complextype

PHP Deprecated issue when running artisan command

Laravel csrf token mismatch for ajax POST Request

Xdebug can't connect back to Docker host

How to get array values using foreach in laravel

About Contact Privacy policy Terms and conditions