• 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

Limit WooCommerce products in cart only from one custom taxonomy

Uploading video to Youtube using Youtube Data API V3 and Google API Client PHP -- getting 401 (unauthorized) message

PHP Array split string and Integers

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

Composer fails with kylekatarnls/update-helper on new homestead

PHP usort() order in case of equality

301 Redirect to remove query string on homepage only

Limit login attempts in Laravel 5.7

Send Outlook 2010 email using PHP

laravel automatically deletes server.php on php artisan serve

Why the name of trucks are same in 2nd and 3rd record of company data retrieval?

send email using gmail-api and google-api-php-client

How to get total pages of PDF with FPDF?

Call to a member function givePermissionTo() on null

PhpSpreadSheet: How to save Workbook sheets in individual CSV files

About Contact Privacy policy Terms and conditions