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.

0
votes
0answers
43 views

Displaying elements of nested associative arrays in SystemVerilog

I am trying to access/print individual elements of a nested associative array, here is some code to clarify /* Creating an associative array(AA) called timings such that each key contains an AA ...
0
votes
1answer
50 views

How to check if elements of a multiplication table are all associative?

I want to check if a multiplication table like the following is not a code but I could not find a way to write it another way * 0 1 2 0 |0 1 0 1 |0 0 0 2 |0 1 1 It is store as a list with ...
0
votes
2answers
55 views

foreach loop output first value only in loop

Why foreach loop printing only the first value from the array? $Jdata_cate ='[{"category_id":"103","name":"Martin","parent_id":0},{"category_id":"10","name":"Juan","parent_id":0},{"category_id":"9","...
0
votes
1answer
31 views

System Verilog Nested Associative Array

How do you declare an initialize a nested associative array in System Verilog? /* Creating an associative array(AA) called timings such that each key contains an AA with a list of relevant key ...
1
vote
1answer
33 views

Undefined index in array but it is there

I have an array called $csv. The header columns are contained within $csv[0]. I have a loop that goes in and overwrites some data in the $csv array starting at index 1. For some reason it is no ...
1
vote
0answers
32 views

How to prevent syntax errors when reading BASH associative array values which contain slashes from a child process?

I'm using bash 4.4.19(1)-release. At the start of my program I read customer configuration values from the command line, configuration file(s), and the environment (in decreasing order of precedence)....
0
votes
1answer
39 views

Generate bar chart using chart.js and associative array

I have associative array and I want to display it using Chart.JS library. My Array: array:4 [▼ 0 => array:3 [▼ "faculty" => "Information Technology" "category" => "ELearning" ...
0
votes
2answers
15 views

How to bind an include to a associative array in php [duplicate]

I have 2 echo's from a php script that are sent as json to the ajax call. These 2 echos will be outputted in 2 different divs. For those 2 echo's , I created an array like below: $result = [ "...
0
votes
2answers
30 views

How can I add a value from one array to a new empty associative array in PHP?

I want to count how many times a number exists in my array, but I want to do it like this. I have an empty array like this: $aNumberArray = array(); And I have an array like this: $aArray = (4,4,5,...
1
vote
2answers
77 views

Why index gets automatically created in javascript array?

If I try to create an associative array using digit as property, it's inserting other values automatically with null values. I tried passing a string (myArray['myProp']), array length is zero that ...
0
votes
2answers
57 views

Push element at each index in an array

I have an array, i wan to add one more key value pair at each index. var ajaxResult = ajaxGet("URL"); if (ajaxResult.length > 0) { for (var i = 0; i < ajaxResult.length; i++) { ...
0
votes
2answers
52 views

Facing issue with binding Data from JSON Object to <mat-select>

I am having trouble in populating the drop-down list from the JSON Response object coming from the API.. component.ts code for (let k in keys) { this.form.controls['id'].setValue(data[k]....
0
votes
2answers
43 views

Missing value in associative array, but value visible with var_dump()

I have a simple associative array called $product. This is how it looks with var_dump[$product] array(5) { ["sku"]=> string(9) "001R00610" ["name"]=> string(28) "Xerox 001R00610 ...
4
votes
1answer
103 views

array_slice for associative array

I have an array with indexes as timestamps. I tried array_slice to get all values between a time range but it doesn't seem to work. $data = array_slice(["1549440811" => 1, "1549448226" => 2, "...
-1
votes
5answers
115 views

Loop Multidimensional PHP arrays and display all the corresponding array

I've found an almost similar problem on this topic [link text] Loop Multidimensional PHP arrays My array is a little different but almost similar : > Array > ( ...
0
votes
1answer
22 views

how to skip iteration of while loop in associative array means we want to execute first ,second, fourth,fifth like this?

i am creating a CMS system. if post is not published then it will not render in html otherwise show in html. So if I fetch a associative array from database "cms" then it has some published and ...
1
vote
1answer
40 views

How to pass associative array to Gnu Parallel [duplicate]

Like in a title, I've declared bunch of variables and a function. And when I pass them through a function I've got what I expected. But running same code through parallel didn't... How to fix it? #!/...
0
votes
0answers
24 views

Choose the key of a nested object according to a value stored in an array inside it in mongodb in aggregation

I have schema of the form as shown below, after a few stages of aggregation pipeline. { _id:"uid1", x:{ ab:{ u:["uid1","uid2","uid3"] }, pq:{ u:...
0
votes
3answers
28 views

Array with similar value being removed

Basically, I've list of associative array and I'm trying to output both key and value for all. Here's the code I have. $sites = array("www.google.com" => "Google", "www.apple.com" => "Apple", ...
0
votes
3answers
17 views

PHP problem with array_push(mainArr, subAssociativeArr) inside a function

the array_push(mainArr, subAssociativeArr) does not work when it is inside a function. I need some help with this code: $store=array(); $samsung=array('id'=>'10','name'=>'samsung'); $sony=...
0
votes
2answers
65 views

PHP `json_encode` incorrectly turn array into `{}`

My system is centos 7.4 with PHP 5.4 $s='a:91:{s:13:"spotsviewvars";s:7:"1916.74";s:13:"100000T18vars";N;s:17:"100000T18S106vars";s:7:"1746.95";s:17:"100000T18S107vars";s:4:"4.49";s:17:"...
0
votes
2answers
53 views

Find specific element from multidimensional array in PHP

I have a multidimensional array that I use to build a navigation menu. It may consist of any number of submenus (or children). The menu works just fine. When someone clicks on a menu link, the product ...
3
votes
1answer
38 views

Sorting out associative arrays according to values

In each element of the array, the second value points to the parent of the element itself. So for instance in the first array, "City" is the root element and "Area" is the first child, because the ...
1
vote
3answers
47 views

PHP array_filter in multidimensional associative array

I need to find the value for a key by searching for another value within the same array of a multidimensional array. This is the given array: <?php $users = array( "userA" => array( ...
1
vote
0answers
31 views

php procedural prepare with associative array

I need to use a prepare statement to get an array of results, and my experience till now is all in procedural way. This is the code where I need a hand: Before this I have a require statement with a ...
0
votes
0answers
33 views

php global associative array null when included from ajax

i have a problem that i cannot understand. i have a file declaring some arrays and some function : passerelles/zoho_API_START.php you can see the array declaration at the beginning of the file : $...
0
votes
1answer
15 views

Assigning multiple associative to one

I am trying to add a question and I have 4 options for that question. Among those options, only one will be the correct of course. But, after submitting the form, I am receiving the data like the ...
-1
votes
1answer
31 views

Compare only values of arrays and get difference

I have two arrays like below; array1 = { [0]=> 'A' [1]=> 'B' [2]=> 'C' } array2 = { [0]=> 'B' [1]=> 'C' [...
0
votes
2answers
42 views

PHP Insert array to associative array at specific position

I want insert one array to another associative array at specific position, but for me the array_splice doesn't work. I want do this: $example = [ 'first' => 'element', 'second' ...
-1
votes
1answer
41 views

Adding to an associate array in PHP using a loop

$usepassArray = explode(",", $implodedstuff); for ($i = 0; $i < sizeof($usepassArray) ; $i = $i + 2) { $finalArray += array($usepassArray[$i] => $usepassArray[$i + 1]); } So my $...
2
votes
0answers
40 views

Cannot access value of associative array in JavaScript [duplicate]

Context: I am successfully reading a CSV file into an array with d3. The data consists of personal IDs (which occur multiple times) and of one item (out of A, B, C, D, E, F, G) associated with the ID. ...
0
votes
1answer
41 views

PHP: Convert array to indexed array

Given I have an simple non-associative array $values of SomeObject items indexed by 0, 1, 2, etc. What is the best syntax to construct associative array $valuesByIndex indexed by some value extracted ...
2
votes
4answers
76 views

Displaying formatted records using AWK

I have been giving an input file where it looks as this: ID PID PPID C STIME TTY TIME CMD adz110 5344 5334 0 08:47 pts/2 00:00:00 bash dmq292 6908 6854 ...
0
votes
1answer
53 views

multiple values to a key in tcl array

Ho do I specify multiple values to a key in Tcl associative array? set A(a) val1 set A(a) val2 This is overriding the value and, on printing, I get the last value. How to store and to retrieve both ...
-1
votes
1answer
39 views

How to filter and loop through a nested associative object in JavaScript?

So I have three nested associative objects/arrays in total. Employee1 and employee2 were first made, and then employees was created in order to nest the two associative objects. Next, I created a ...
0
votes
1answer
23 views

Array only getting first part of data

When you echo this specific code to see the data ,it only shows the first part of the array and not the second index, is there a reason for this? $arrChartData = array( "seriesname" => "ACT", ...
0
votes
2answers
68 views

How to sort array of object in javascript by its property value?

Have an object array like: I want to sort itemsArray by its sortOrder. Here is the sortOrder of item (itemsArray['item=a37d2733-f710-4e47-8573-6aab11f6d020'].sortOrder) { "Items": [ { "...
0
votes
1answer
39 views

PHP: HTML to PHP multidimensional associative array

Using xPath query, I am trying to extract HTML values and put them into an associative array in PHP. I am using a loop to get the rows and cells from the table. But, I can;t figure out how to get the ...
1
vote
3answers
49 views

Array search on manually generated associative array (different column names)

Lets say I have an array like below $array = array( array( //index 0 'col_1' => 'one', 'col_2' => 'two' ), array( //index 1 'col_5' => 'five', 'col_3' => 'three' ) ...
0
votes
4answers
96 views

PHP - Get all values that has been checked in checkbox and combine it in one array

I had no problem on getting the values from HTML form but my problem is how to combine all values that I got in one array? Example: Quantity[] is separated from CheckBox[]. If the checkbox has ...
0
votes
1answer
40 views

Sorting Multi Dimensional Array with PHP [duplicate]

I have below array with me: Array( [0] => Array( ['sort'] => 1 ['ques'] => 'Zing order' ) [1] => Array( ['sort'] => 1 ['ques'] => 'How stackoverflow works?' ...
0
votes
1answer
25 views

I need help sorting a multi-dimensional array by date [duplicate]

I'm having trouble sorting this multi-dimensional array by date. I want $list_array to be sorted by the 'date' $list_array = array ( array("date"=>"2020-01-02", "address"=>"1629 W Main ...
0
votes
0answers
85 views

Moving columns in associative list in Ocaml

I am trying to move a column in an associative list. I am given the source column and the destination as well. My goal is to, upon finding the element with the matching column source, move it to its ...
1
vote
0answers
57 views

ORA-21700: object does not exist or is marked for delete for Associative Array as input parameter called from ODP.NET

I have this package code on Oracle 12c CREATE OR REPLACE PACKAGE Support_Data_Types AS TYPE ttDate IS TABLE OF DATE END Support_Data_Types; PROCEDURE GetData ( tabDates IN ...
1
vote
1answer
62 views

Associative array in bash not storing values inside loop [duplicate]

This is my $a output: [root@node1 ~]# echo "${a}" /dev/vdc1 /gfs1 /dev/vdd1 /elastic mfsmount /usr/local/flytxt I gotta store these in an associative array fsmounts with first column as keys and ...
2
votes
2answers
53 views

PL / SQL word count from string

can you please help me how to count words in string? It is format like: n_var VARCHAR2(1000) :='Hello, I like ham pizza more than mozzarella pizza.' I need output something like this: hello => 1, ...
3
votes
2answers
70 views

How to create a multi-dimensional array from an indexed array in PHP?

I have a 2D array that its first dimension is an index array and the second one is an associative array. In the array, there are some duplicates fields that I want to merge them, and for the other ...
0
votes
2answers
28 views

PHP remove element form array is not working properly

I am trying to remove Product element using unset from the array but it's not working. also, need to insert this array using MySql. How can I achieve this? unset( $ar2['Product'] ); print_r($...
0
votes
1answer
25 views

Filter NSArray of Arrays by One Element of Array Using NSPredicate in IOS

It is possible to filter an array of strings as follows: NSArray *array = @[@"honda",@"toyota",@"ford"]; NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@",@"ford"]; ...
0
votes
1answer
39 views

How to format associative array

I have this code: <?php error_reporting(E_ALL);ini_set('display_errors', 1); require 'config.php'; $query = $_GET['q']; if ($query==null) { exit('No query'...

http://mssss.yulina-kosm.ru