• 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

Merge column values from two arrays to form an indexed array of associative arrays

Laravel insert dynamic input values with radio button

Transform array, set each array element with parent key php

Laravel websockets AWS EC2 - Connection failed

Wordpress wpdb->delete issue

PHP Array split string and Integers

Converting alphabet letter to alphabet position in PHP [duplicate]

How can I make good efficent AJAX live forms with just jQuery and

How to use React Router with Laravel?

if statement inside concatenation

How can I convert from a{a{} b{}} to a[a[],b[]] using php preg_match?

Transpose multidimensional array and join values with commas

I want to store data in new index as per my key in php [duplicate]

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

Laravel multi auth - Authentication user provider [] is not defined

About Contact Privacy policy Terms and conditions