Questions tagged [associative-array]

An associative array is an abstract data type composed of a collection of unique keys mapped to a collection of values.

An associative array (also associative container, map, mapping, dictionary, finite map, and in query-processing an index or index file) is an abstract data type composed of a collection of unique keys and a collection of values, where each key is associated with one value (or set of values). The operation of finding the value associated with a key is called a lookup or indexing, and this is the most important operation supported by an associative array. The relationship between a key and its value is sometimes called a mapping or binding. For example, if the value associated with the key "bob" is 7, we say that our array maps "bob" to 7. Associative arrays are very closely related to the mathematical concept of a function with a finite domain. As a consequence, a common and important use of associative arrays is in memoization.

See also

3174 questions
1
vote
1 answer

Combining MANY JSON objects? - PHP

I am currently trying to process a relatively large log file which stores game information in JSON. Any log file averagly ranges from 2000-5000 lines. Example output (retaining formatting...) from the logfile, note: I have removed the players name,…
anditpainsme
  • 601
  • 1
  • 7
  • 14
1
vote
2 answers

Loop through 2 rows, merge and remove duplicates

I have 2 rows in a mysql table. Some of the data is duplicated across the rows, and some is duplicated in the same row. I would like to echo out each unique value. The array looks like this: Array ( [0] => Array ( [Character1] => Moe Szyslak…
jaybong
  • 317
  • 3
  • 14
1
vote
3 answers

Sorting a value pair in Javascript

I must be missing the proper term or else I'm sure I could find the answer by searching... in any case, here's what I want to do. Through javascript, I get four variables (A, B, C, and D) that I would like to sort, and still keep track of the…
1
vote
2 answers

Adding an key=> value pair comparing the **key of one array** with the **value of another array**

I have an associative array (name = $holidays) like below. Each key might or might not point to a value. If a key points to a value that value is an array as shown below. (key [4] points to an Array which has the key=> value pair [override] => 1…
Les_Salantes
  • 317
  • 6
  • 20
1
vote
2 answers

Sum of multidimensional associative array PHP

Array ( [Sum_1] => Array ( [0] => Array ( [e] => 1000001 [u] => Test1 [a] => 775.00 …
1
vote
5 answers

Removing a key=>value pair from a 3D associative array - PHP

The 3D assoc. array looks like below. Array ( [COL] => Array ( [0] => Array ( [emp_num] => 1000001 [user_name] => Test…
1
vote
3 answers

not able to get the keys of an array having duplicate values in php

after some codings i get a dynamic array like this. it may increase with more values according to data. but this following is a sample. Array ( [11-23-1] => 5 [17-29-2] => 5 [9-21-1] => 3 [10-52-2] => 5 [17-30-2] => 3 …
user1638279
  • 523
  • 2
  • 12
  • 26
1
vote
2 answers

Array looping order issue

Hey all i am trying to get my array in the correct format to be placed into an ASP.net webpage for a table for an order. The order should be: model_number comm_category service freight sales_tax sales unit_price price id_price Currently it is…
StealthRT
  • 10,108
  • 40
  • 183
  • 342
1
vote
1 answer

Error printing an associative array (error:unexpected "", expecting T_STRING or T_NUM STRING)

I have the code: print <<$myInfo["lastName"]

HERE; and get the error: error:unexpected "", expecting T_STRING or T_NUM STRING What is the problem?
fall
  • 984
  • 11
  • 33
1
vote
1 answer

How to order this tricky PHP associative array?

How to order this tricky PHP associative array? I have this associative array: Array ( [4] => 3 [2] => 4 [3] => 1 [6] => 1 [1] => 1 ) I need to order it by key with highest value, BUT I also need to keep the keys with the same…
user2781234
  • 13
  • 1
  • 3
1
vote
2 answers

multidimensional array - adding a key and value where a key and value is matched

I'm trying to add a key and value (associative) from an array to another array, where one specific key and value match. Here are the two arrays: $array1 = array( 1 => array( 'walgreens' => 'location', …
user791187
  • 657
  • 3
  • 11
  • 23
1
vote
2 answers

Access SimpleXMLElement Object Values

I have the following SimpleXMLElement Object http://pastebin.com/qEP0UUPJ I can query it using xpath $xaugbp = $xml->xpath("/query/results/rate"); but this just narrows down the search: http://pastebin.com/Xwezx4bZ I wish to access the following…
Gravy
  • 12,264
  • 26
  • 124
  • 193
1
vote
2 answers

Getting the Index of an Array of Associative Arrays in Javascript

I have an array of "associative arrays," i.e. objects, that hold the data of various HTML elements and one other parameter like so: container[0] = { picker_canvas: document.getElementById("background_picker"), color_canvas:…
Huub Mons
  • 149
  • 1
  • 11
1
vote
4 answers

Java member variables as associative array like AS3

In ActionScript 2 and 3, we can access a member variable of a class like it is in an associative array. for eg., //AS3 Code private var tempvar:String="Hello"; function printString() { trace(this.tempvar); …
Tirtha
  • 862
  • 1
  • 12
  • 29
1
vote
3 answers

Merging two objects in JavaScript

I have two JavaScript objects: var attributes1 = { "type": "text/css", "rel": "stylesheet", "href": baseUrl + "Styles/HtmlLibrary.css" }; var attributes2 = { "type": "text/css", "rel": "stylesheet", "href": baseUrl +…
Ovi
  • 2,459
  • 9
  • 50
  • 72
1 2 3
99
100