• 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

Having issue with matching rows in the database using PDO

Codeigniter, Severity: error --> Exception: Too few arguments to function, admin dashboard shows HTTP error 500

Show date difference as "20" instead of "20 years ago"

PHP: Print caught exception like Xdebug

Navigation idle on content download

Shopify password update using Shopify API

How to create a individual template for page or post in custom plugin?

How to reset Laravel AuthManager/guards in between API calls in tests?

phpmyadmin : Depends: php-twig (>= 2.9) but 2.6.2-2 is to be installed. WHAT?

php file upload scanning using clamav, permissions on /tmp/

Calculating Median of an array in PHP

How do I call Validator from a namespace with an already existing Validator class

PHPMyAdmin not working as intended at remote server. Error 500, $respond not found

How can i call a function that executes an fpdf based on the choice of a form selector?

How Can I Do LIMIT 1, 2 In WP_Query

About Contact Privacy policy Terms and conditions