• 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

Custom add to cart button URL for specific product in WooCommerce?

Exact alternate to mcrypt_encrypt in PHP 7.2

How to loop sql table data inside a html table

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

Laravel 5.1 Unknown database type enum requested

Live search query using JS and PHP for QA forum

Return multiple values from a function using mysqli_fetch_assoc [closed]

Laravel/ PHP: Order By Alphabetical with numbers in order [duplicate]

how to sort by a custom appended relation to model

Log a user out of a website when they put their computer to sleep

Navigation idle on content download

Laravel implode array items to new lines

Class AppHttpControllersUserController Does Not Exist

How to check user Permissions using Custom Middleware in Laravel

How to use functions that are declared in snippets in Evolution CMS (Modx) in an external PHP Script?

About Contact Privacy policy Terms and conditions