• 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

Printing more than one array using print_r or any other function in php

Printing more than one array using print_r or any other function in php

Merge key and value of array index [duplicate]

How to increase the PHP upload limits [duplicate]

Merge key and value of array index [duplicate]

Split a string array into pieces

PHP drop down list using array's and foreach (else and for) code

Normalize DateInterval in PHP

Why isn't my PHP exception working?

Cannot retrieve error message using Symfony HttpClient if the response is not "ok"

Getting error: CodeIgniterDatabaseBaseResult::getResult in CodeIgniter

Testing subscription renewals on Stripe

Jquery DataTables: Data not displaying in table via Ajax

How to add a custom field to all Woocommerce attribute terms using add_action

How to send image,audio or video through the WhatsApp API - PHP

About Contact Privacy policy Terms and conditions