![]() * Second method to create an associative array. The code below will assist you in doing so.To do so, you can use an associative list.Let's say you have a group of people and you want to assign gender to each of them based on their names.“$variable name.” is the variable's name, “” is the element's access index number, and “value” is the array element's value.Instead, you can use the employees' names as keys in an associative list, with their salaries as the value. The index of an associative array is a string that allows you to create a strong link between key and value.Ī numerically indexed array is not the best option for storing employee salaries in an array. ![]() In terms of features, associative arrays are very similar to numeric arrays, but they vary in terms of the index. A better and more effective option would be to use the names of the subjects as the keys in your associative list, with their respective marks as the value. For instance, If you need to store marks earned by a student in different subjects in an array, a numerically indexed array may not be the right choice.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |