Index arrays with string in PHP

Description

The following code shows how to index arrays with string.

Example


<?php/*w  w w .  j a v a  2 s .  c o m*/
  // fill in some information
  $UserInfo["Name"] = "Jack";
  $UserInfo["Location"] = "Main Street, California";
  $UserInfo["Occupation"] = "Programmer";

  //loop over values
  foreach($UserInfo as $key=>$value)
  {
    print("$key is $value.<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