This tag is used mostly regarding associative arrays (but better use tag "associative-array" for that) and sometimes in the mathematic sense of tag "associativity", the associative property of binary operations.
Questions tagged [associative]
435 questions
2
votes
2 answers
Look for duplicate values in a associative array and add them to a count
Hi I am trying to count the number of duplicate values in a associative array that looks like this:
array(3) { [0]=> array(3) { ["Title"]=> string(25) "hello"
["Price"]=> int(50)
["Count"]=>…

user1593846
- 734
- 1
- 15
- 34
2
votes
1 answer
*FIXED* Good with PHP arrays? HELP!
I know there are a lot of smart people, so prove me right!
I want to combine arrays where similar named keys merge together to form a single array. See example:
[Bob] => Array
(
[BobsDetails] => Array
(
[Title] => Mr
)
)
[Bob] =>…
David G
2
votes
1 answer
Possible to prevent MySQL from renaming key after 'UNCOMPRESS'?
So I'm storing some XML in a table, and using the MySQL 'COMPRESS' function like this:
$query = "SELECT UNCOMPRESS(table_row) FROM database WHERE this = 'that'";
$mysqli = $this->ConnectDB();
$result = $mysqli->query($query);
$task_result =…

jbrain
- 561
- 3
- 7
- 18
1
vote
2 answers
Indexed/numerical array to an associative array with PHP
Is there anyway that an indexed array say ['1' => 'dave, '2' => 'ryan', '3' => 'mike', '4' => 'sam'] can be turned into an associative array. Which in this case would be ['dave' => 'ryan', 'mike' => 'sam'].
Obviously in the context and with the…

RyanM
- 53
- 4
1
vote
3 answers
MySQL Query Help: Getting content from associated table with position
What I need to do
I have two tables, "chapters" and "pages".
Each chapter has many pages.
Chapters are sorted by a position column.
Pages are sorted by a position column relative to its Chapter. So the first page in each chapter has a position of…

yourfavorite
- 517
- 8
- 21
1
vote
4 answers
php get values from this type of associative array
How can i get the firstName values from this array?
its easy with print_r, but I want individual values
Array
(
[0] => stdClass Object
(
[id] => 106288917
[firstName] => xxxxx
[lastName] => yyyyy
…

matt
- 2,312
- 5
- 34
- 57
1
vote
1 answer
Codebook OTHER value
I have a problem regarding my current CodeBook.
CodeBook is an entity that consists of two attributes, the Code and Description.
It is an abstract class. I extended that class with the Class Domain.
Domain class is also an abstract class and…

zevonja
- 193
- 1
- 14
1
vote
1 answer
Save Informations as a Data Net
My aim is to write an intelligent ChatBot. He should save known informations likely to the human brain.
That is why I am looking for a filetype wich stores data as a net of connected keywords. What filetype or database system could reach…

danijar
- 32,406
- 45
- 166
- 297
1
vote
1 answer
Strange behavior with array as static class property
Can I have an associative array as a property of a class?
I have been trying but I get very strange results on something like this:
class MyClass {
public static $quality = array('blue' => 20, 'green' => 30, 'yellow' => 40);
public $car =…

Dentra Andres
- 371
- 1
- 7
- 18
1
vote
2 answers
Troubleshooting "Notice: Undefined index", but index appears to be defined
I have this piece of code:
]*>(.*?)";
$html = file_get_contents("http://www.bicicletapublica.com.ar/mapa.aspx");
$results = array();
preg_match_all($pattern, $html, $results );
$results = $results[0];
$stations =…

Topicus
- 1,394
- 1
- 15
- 27
1
vote
0 answers
Are floating point numbers really commutative?
It's said that floating point addition is commutative but not associative.
An example of it being non associative is the following:
(1 + 1e100) + -1e100 = 0, and 1 + (1e100 + -1e100) = 1
But doesn't this also prove that they are not commutative by…

Sea Erchin
- 31
- 3
1
vote
1 answer
html checkboxes associative array - how to access this array in javascript?
I'm trying to do this:
and get access to this array in javascript like this
1.
var myarr…

Kirill Universum
- 11
- 2
1
vote
2 answers
Bash: Is there a built-in way to get the maximum length of the keys in an associative array
In Bash, given an associative array, how do I find the length of the longest key?
Say, I declare myArray as shown below:
$ declare -A myArray=([zero]=nothing [one]='just one' [multiple]='many many')
$ echo ${myArray[zero]}
nothing
$ echo…

vtbr
- 13
- 3
1
vote
1 answer
For each to get keys and values from associative array doesn't return all keys and values if they share the same key name - PHP
I'm reading a file that has this text:
Vélez Sarsfield|Zárate, Mauro|8|0|0|1|9
Estudiantes|Carrillo, Guido|5|1|0|2|8
Boca Juniors|Gigliotti, Emanuel|3|2|0|2|7
River Plate|Carbonero, Carlos Mario|4|2|0|0|6
Arsenal|Echeverría,…

le0nicolas
- 83
- 10
1
vote
1 answer
"message": "Illegal string offset 'product_id'", "exception": "ErrorException",
$json = file_get_contents('php://input');
// Decode the received JSON and store into $obj
$obj = json_decode($json,true);
foreach($obj as $product){
$product_id = $product['product_id'];
…

DANIEL
- 76
- 1
- 7