Answers for "php build array"

PHP
2

php initialize array

// Initialize Empty Array (PHP 5.4 and higher)
$myArray = [];

// Initialize Empty Array (Before PHP 5.4)
$myArray = array();
Posted by: Guest on May-01-2020
4

php array

<?php
$array = array(
    "foo" => "bar",
    42    => 24,
    "multi" => array(
         "dimensional" => array(
             "array" => "foo"
         )
    )
);

var_dump($array["foo"]);
var_dump($array[42]);
var_dump($array["multi"]["dimensional"]["array"]);
?>
Posted by: Guest on June-17-2020

Browse Popular Code Answers by Language