• 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

LARAVEL: How to fetch id dynamically in a query builder?

PHP array, move keys and values to new array, but mix it up

Wordpress wpdb->delete issue

Is it possible to re-use an array taken from PHP via JSON in a $.ajax function?

Using Associative arrays

Implode columnar values between two arrays into a flat array of concatenated strings

How to debug in WooCommerce 3+

calling server using nusoap with complextype

Issue with laravel eloquent model property

SQL to convert multiple rows into a single row of variable length

"Unable to load dynamic library 'pdo_sqlsrv.so' "Cenos7 PHP7.2.10

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

PHP: How to quickly split a key=value file into associative array

Toggle between a textbox and a select using PHP

Split array into 4-element chunks then implode into strings

About Contact Privacy policy Terms and conditions