• 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

WAMP Virtual Host not working

Getting output of MS stored procedure on php call

CodeIgniter force_download is not working

Maatwebsite Excel 3.1 : how do I skip duplicate data when imported?

AJAX call fails with SyntaxError: Unexpected end of JSON input

Convert every two values of an associative array into key-value pairs

Php - Sum up the numbers in an array one by one

What is PHP's equivalent of JavaScript's "array.every()"?

PHP web3 ERC20 token function call

Dynamic table in HTML using MySQL and php

Sync Records With Default Values in Pivot Tables, Call to undefined method syncWithPivotDefaults()

Cannot connect to own websocket server when on secured domain

sqlsrv_num_rows() expects parameter 1 to be resource, boolean given

Spam Filter in Contact Form

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

About Contact Privacy policy Terms and conditions