• 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

Check if string contains a value in array [duplicate]

How to convert a carbon into string, to take the date only?

GuzzleHttp Hangs When Using Localhost

Not able to access model in the controller mautic

Installing Composer - Internal Error

Adding reCAPTCHA v2 into my PHP file

Reorder attribute dropdown terms in Woocommerce single variable products

Having trouble with PDO queries (Notice: Undefined index)

PHP array sort and remove duplicates by two field values

How to unlink image from folder?

Group data in a multidimensional array based on two columns

how to check version of codeigniter framework?

WooCommerce: Add/display Product or Variation custom field everywhere

How can I format this number correctly using PHP?

Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables 11 [closed]

About Contact Privacy policy Terms and conditions