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
1
vote
1 answer
simple 1D example showing convolution vs correlation to test commutative/associative property
So I've known this fact that convolution has commutative/associative property while correlation does not but never really written out a simple example to test this out. (proofs in equation forms exist out there)
I was just trying this simple…

Han Brian Lee
- 11
- 1
1
vote
2 answers
JavaScript Object efficient for an associate array (AKA Map)? What alternatives are there?
I am new to JavaScript and lately been coding in PHP which I am looking to port to JavaScript. PHP has a Map implemented directly into its Array container class, which does not exists in the default language of JavaScript.
Everyone I seem to read…

j_p
- 29
- 5
1
vote
0 answers
bash - associative array subscript - "not a valid identifier"
Does bash impose constraints on the characters used in associative-array subscripts? I have successfully used string subscripts that include spaces, but am tripping on a (bug?) when the subscript includes a quotation mark.
bash-5.0$ declare -A…

David
- 19
- 2
1
vote
2 answers
I can't get a value to stay in my $_SESSION variable
I am trying to get values out of an indexed array, but when I use a variable as the index (which is equal to an index in the array), it does not appear. I get an Undefined Index Error. Why is this happening? Does anyone know? Thanks!
I have the…

EGr
- 2,072
- 10
- 41
- 61
1
vote
3 answers
How to associate and filter two related arrays?
I have two arrays and I want to link together when processing them.
$dat = array(
"2020-02-01",
"2020-02-05",
"2020-02-10",
"2020-02-12",
"2020-02-15"
);
$word = array(
"Attend To,Explore,Unaided,dull,bad"
);
//User…
user13465228
1
vote
2 answers
Converting a json object to an associative array
I have this array which is retrieved by a json_encode().When I execute
$.getJSON('beta.php' , function(data){
console.log(data);
});
I get the result as follows
[
Object { StuId="1", fName="Saman", more...},
Object { StuId="2", fName="Marry",…

SriniShine
- 1,089
- 5
- 26
- 46
1
vote
2 answers
Multiple values for a key in ksh
I'm trying to read a file which is in pairs as follows:
V1#K1.@
V2#K1.@
V3#K2.@,V4#K1.@,V5#K2
V1#K3.@
My aim is to store it in key<=>pairs with # as a delimiter after removing '@' Value is placed before # and Keys are after # in the example…

anurag86
- 1,635
- 1
- 16
- 31
1
vote
2 answers
Send data from an Object to a React Component
Access to data inside an object to send it to a React Component
I'm trying to recover data inside an object which looks like this :
{89: {…}, 91: {…}, 92: {…}}
89: {name: "Confiture de Myrtilles", product_id: "737", _wc_review_count: "0",…
1
vote
1 answer
Access bash associate array via variable indirection
I wish to access an associative array using a variable. The example in the accepted answer to this post is exactly what I want:
$ declare -A FIRST=( [hello]=world [foo]=bar )
$ alias=FIRST
$ echo "${!alias[foo]}"
however this does not work for me…

John
- 451
- 7
- 17
1
vote
1 answer
Creating associative array from object
I currently have an array that is building with the correct data by looping an object but it's giving the incorrect format:
$priceResult = array();
foreach($prices->categories as $category){
$priceResult[] = $category->category_name;
…

Geoff_S
- 4,917
- 7
- 43
- 133
1
vote
3 answers
How to get column names and values from a single-row resultset with PDO?
I need to get all column names and values in the row where id = $id.
Column names should be echoed as title; values should be echoed as story
Something like this:
function story($id) {
global $db;
$sql = "select * from users where id =…
user7461846
1
vote
2 answers
Functor associative law confusion
I've been confused by associative law of functor(Endofunctor) for weeks.
I know every endofunctor forms composition/associative feature.
Composition is associative. Basically that means that when you’re composing multiple functions (morphisms if…
user6440264
1
vote
1 answer
Associative Lists in Prolog
my task is to implement maps with lists. We defined associative lists as follows:
[] is the list,
k is a key, v is a value and a is an associative list, then [[k, v] | a] is an associative list.
so now ive got to write a predicate, in which it…

Sleeyz
- 25
- 3
1
vote
2 answers
PHP Transform mixed sequential and associative array to associative array
I would like to build $goal array from $initial only. Any ideas? Thank you
Edit : the question could be how to differentiate associative parts from sequential ones.
$intial=[
"one",
"two"=>"myTwo",
"three",
…

tit
- 599
- 3
- 6
- 25
1
vote
2 answers
selected attribute between
I'm looking for some guidance here where I've struggled to get working.
I have an associative array with the following options:
$options_format [] = [
'name' => 'Audio',
'type' => 'Audio',
];
$options_format [] = [
'name' => 'EBook',
…

Developer Jay
- 953
- 1
- 10
- 15