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

RegisterLogin
How To Index Arrays And Show All The Elements And Values Of Array
Post Description: How To Index Arrays And Show All The Elements And Values Of Array
Tags: How, To, Index, Arrays, And, Show, All, The, Elements, And, Values, Of, Array
This Post Was Posted On Feb 29, 2008 By web hosting #1896

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
©2011 Webune Forums - Wed Dec 21, 2011 3:34 am
Powered by: Webune Forums V3