How To Index Arrays And Show All The Elements And Values Of Array



How To Index Arrays And Show All The Elements And Values Of Array
How To Index Arrays And Show All The Elements And Values Of Array
Post Description:
Post Tags: how, to, index, arrays, and, show, all, the, elements, and, values, of, array
This Post Has Been Viewed 333 Times Since Sun Feb 24, 2008 12:07 pm Posted By hostman with 0 replies
How To Index Arrays And Show All The Elements And Values Of Array

indexing arrays with string



so far i've only seen arrays indexed by itergers, but it is also permissbible to use strings. sometimes there are called assocaited arrays, or hashes. they are helpful in situations where you are colectin differen type so information into one array. you could build inot your code a system where element zeor is a name, element one is a location, and element two is an occupation

here is an example:

<?php
// fill in some information
$userinfo["Name"] = "John Doe";
$userinfo["Location"] = "San Francisco";
$userinfo["Occupation"] = "Programmer";

foreach($userinfo as $key=>$value) {
print("$key is $value.<br>");
}
?>


the above will output:
Name is John Doe
Location is San Francisco
Occupation Programmer

Leave Your Comments     [ dejar commentarios ]
  * Name     [nombre]

  * eMail (will not be published)     [coreo electronico]

* Enter Your Reply or Comments:    [commentarios]


Add Picture To Comments         [incluir foto]
YES NO             upload
Receive Replies on my Comments (An email will be sent to you when someone replies to your comments)

     

Comments and replies About How To Index Arrays And Show All The Elements And Values Of Array




(0) Comments