Member Avatar

What is need of Associative Arrays when Indexed arrays is present.
Please Suggest.

Thankx.

Recommended Answers

Indexed arrays have the numeric value in the index
$array[0]="XYZ";
$array[1]="25";
$array[2]="United States";
$array[3]="Football";

where as

Associative arrays have the text value (key) in the index
$array['Name']="XYZ";
$array['Age']="25";
$array['Country']="United States";
$array['Game']="Football";

It depends on person and the logic he want to build where he want to use the array.

Suppoese …

Jump to Post

All 2 Replies

Indexed arrays have the numeric value in the index
$array[0]="XYZ";
$array[1]="25";
$array[2]="United States";
$array[3]="Football";

where as

Associative arrays have the text value (key) in the index
$array['Name']="XYZ";
$array['Age']="25";
$array['Country']="United States";
$array['Game']="Football";

It depends on person and the logic he want to build where he want to use the array.

Suppoese using above array example I am storing a person's information. Which one is most specfic developers point of view?
I think associatve array which tells the meta information that which information is stored in that.

Member Avatar

@arunmagar: I see your point.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.