• 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

html-php form submission after validation through JavaScript [closed]

oauth-private.key does not exist or is not readable

Unable to Edit config.inc.php

jwt decode throws Invalid argument supplied for foreach() on php-jwt and codeignitor 4

Select option menu read from database and use it's values

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

retrieve data from database using session

How to put php code inside opening and closing shortcodes

How to create laravel storage symbolic link for production or sub domain system?

Laravel no logout option from menu after successfull login

Laravel Unknown Column 'updated_at'

Chunk and transpose a flat array into rows with a specific number of columns

Can't find vendor/autoload.php for Ratchet

How do I pass the dynamic output of a php variable or php function to a CSS variable?

Having issue with matching rows in the database using PDO

About Contact Privacy policy Terms and conditions