Member Avatar for Rahul47

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

Thankx.

Recommended Answers

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 for Rahul47

@arunmagar: I see your point.

Be a part of the DaniWeb community

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