Initialize an array in PHP

Description

The following code shows how to initialize an array.

Example


//  www.j av a  2 s. c  om
<?php
  $monthName = array(1=>"January", "February", "March",
    "April", "May", "June", "July", "August",
    "September", "October", "November", "December");
  print("Month 5 is $monthName[5]<br>\n");
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone