declare array php
snippet in php

declare array php

user4578


<?php

$cars = array("Volvo", "BMW", "Toyota");

echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";

?>
 

php array

user5449

<?php 
$fruits = array("Apple", "Banana", "Orange");
echo '<pre>';
print_r($fruits);
echo '</pre>';
?>

php array

user8137


<?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"]);
?>

tab php

user4186

$tab = array(); // empty tab
$tab = array("0" => "Hello", "1" => "world"); // $tab[0]="hello" and $tab[1]="world"