Skip to main content
Filter by
Sorted by
Tagged with
4 votes
4 answers
118 views

How can I map an unknown value alongside other known values in bash using an associative array, so that: #!/bin/bash array=("foo" "foo" "bar" "something else" &...
Caio's user avatar
  • 75
2 votes
1 answer
83 views

Every example I have found tends to go aa["key"]="value" and even with constants, e.g.: declare -rA aa=( ["lit1"]="value1" ["lit2"]="value2" ...
Albert Camu's user avatar
-1 votes
2 answers
215 views

How can I reference an associative array and reassign its content from serialized string? (The eval requirement is now spelled out explicitly in the title, but this is natural when it comes to ...
Albert Camu's user avatar
0 votes
2 answers
87 views

I just started learning Python. I try to create a data structure from the file wg.conf I'm stuck on creating an array Peers. I need to create multiple Peer entries inside that array. Config file ...
Михаил Макрашин's user avatar
1 vote
1 answer
86 views

I am trying to display data from multiple MySQL tables in individual text fields in an HTML form using PHP. Here are three sample tables from a database, followed by code that I am using to select ...
Dave's user avatar
  • 11
1 vote
1 answer
191 views

Here's the code: <?php declare(strict_types=1); /** * @param array{key?: string} $options */ function hello($options) { var_dump($options); } hello([ 'WRONG_KEY' => '...', ]); I ...
Limon Monte's user avatar
  • 54.8k
3 votes
2 answers
199 views

I'm working on a project written in C that's going to be deployed on vintage systems with very limited resources. The target system has at minimum a 16 MHz Motorola 68030 processor with a 256 byte L1 ...
Bri Bri's user avatar
  • 1,992
-7 votes
2 answers
91 views

I get an array of associative arrays of selected company's hierarchy combinations (Some hierarchy levels may be null). For example, if the hierarchy goes division > department > team: [ 0 =>...
pileup's user avatar
  • 3,462
-4 votes
1 answer
138 views

I am trying to build an associative multidimensional array like this: array( [0] => Array( Parent => Mr Smith, Children => array( Firstmane => Bob, ...
SteveAsh's user avatar
1 vote
1 answer
209 views

I want to loop through a JSON object and add the keys and values to a Bash associative array. Here's my JSON object that is in a file named deploy.json. "deploymentEnvs": { "dev":...
mdailey77's user avatar
  • 2,651
0 votes
2 answers
80 views

The following script works as expected for me on FreeBSD using bash-5: function a { declare -gA Seen if [[ -v Seen[$1] ]] then echo "Saw $1 already" return ...
Mikhail T.'s user avatar
  • 4,266
-1 votes
1 answer
73 views

How to dynamically convert a string into (and revert from) UTF8 special font characters "on-the-fly" using PHP functions? For example, echo cvtIntoSpclUTF8FntChars('script', 'Hello, World!');...
James Anderson Jr.'s user avatar
1 vote
3 answers
117 views

The output from the following code does not behave how I think it should. It appears that making changes to the string array returned by testAA.require() does not reflect in the associative array. I ...
Element Green's user avatar
-1 votes
1 answer
52 views

Good morning, I have here: declare A- accocArray1=(["a01"]=1 ["a02"]=2 ["a03"]=3) declare A- accocArray2=(["b01"]=1 ["b02"]=2 ["b03"]=3) ...
haus45's user avatar
  • 9
1 vote
4 answers
114 views

Is there a shorthand for the following code: $result = array_combine( array_map(fn($elem) => "key_$elem", $array), array_map(fn($elem) => "value_$elem", $array) ); ...
plsssineedheeeelp's user avatar
0 votes
2 answers
74 views

I have two arrays, one is a list of status IDs and the corresponding numbers of records that are that status ID. The second array is the names of the statuses. I'd like to tie them together so I have ...
user14989191's user avatar
3 votes
2 answers
126 views

I'm working on a Bash script to calculate GPA for students, taking into account courses that might have been repeated. My goal is to ensure that if a student retakes a course, only the latest grade is ...
kibz's user avatar
  • 31
0 votes
0 answers
55 views

I am writing a web application showing departures from a preselected station. An id of the selected station is saved as a coockie. A JSON file containing id's and full names is read into an array with ...
Clas Östman's user avatar
1 vote
2 answers
358 views

I wrote this code to loop through usernames and domains on my LAN. Sadly, the script prints nothing. #!/bin/bash construct_array_of_trgts() { declare -A usrs_n_dmns local -a guest_dmns local ...
John Smith's user avatar
6 votes
1 answer
170 views

According to man bash it is possible to assign an associative array with a flat list of key-value pairs: […] or a list of words that is interpreted as a sequence of alternating keys and values: name=(...
doak's user avatar
  • 1,015
0 votes
2 answers
156 views

I want to create a dictionary of products where the id is key and the product parameters are custom class that contain the information about the products. It seems like I am storing the information ...
Karlis's user avatar
  • 1
-1 votes
1 answer
218 views

I want to display an array elements in my Vuejs template. I am getting data from API, formatting them into an associative Array with a function and then trying to display in the template : export ...
Jean-Loup's user avatar
  • 398
1 vote
0 answers
47 views

Are there any tools for benchmarking associative arrays? Should be able to benchmark different types of keys, sparse/dense, long/short, few/many . Should perform operations insert, delete, query . ...
jinTgreater's user avatar
1 vote
1 answer
97 views

So, I have such an associative array structure: type CellT = { name: string; value: number }; type AssociativeArrayT = { [key: string]: CellT[] | AssociativeArrayT; }; const myObject: ...
Kirill Kazakov's user avatar
-1 votes
4 answers
91 views

I have a dynamically generated PHP multi-dimensional array as follows: Array ( [uid_1] => Array ( [sub_1] => Array ( [sub_sub_1] => Array ( [id1] => ...
Adrien Hingert's user avatar
-1 votes
1 answer
62 views

I have a php script that returns the images(or files) in a directory. The final output is a json of file names. Below is the code of of what I have now and the result. <?php $files = array(); $...
winfred adrah's user avatar
0 votes
2 answers
91 views

I have the following script: declare -A as1 declare -A as2 declare -a arr=() declare -A sup as1[file]="file1" as2[file]="file2" echo "test: ${as1[file]} ${as2[file]}" ...
learning-man's user avatar
3 votes
1 answer
141 views

I have defined a bash associative array without the explicit declare -A command. But I am not sure if it really is the associative array since I read somewhere without the declare -A, the array is ...
masrur's user avatar
  • 65
0 votes
0 answers
120 views

I am trying to access the last element of a bash associative array using the below code: # Declare an associative array declare -A myAssocArray # Add key-value pairs to the associative array ...
masrur's user avatar
  • 65
2 votes
2 answers
181 views

This Bash function is part of a script that i've recently wrote (following below is a minimal working example of the script with sample data, including an invocation of the function): #!/bin/bash ...
programings's user avatar
1 vote
1 answer
143 views

I´m trying to create this structure to send data to API $metaDataList = [ [ "key" => "item_description0", "value" =&...
scorpions77's user avatar
3 votes
2 answers
123 views

Ran across this apparent anomaly. Test code: ( set -x declare -A a=() for i in x "'" '"' do a[$i]= test -v a[$i] && true done : "${!...
flabdablet's user avatar
  • 3,835
-1 votes
3 answers
222 views

Update As multiple comments have pointed out, associative arrays are not available / supported in Bash 2 or Bash 3. Closing this thread. See below for how we solved the Problem that we were trying to ...
D159's user avatar
  • 409
0 votes
4 answers
145 views

I've the following array: $variables = [ "id" => "discountCodeID", "test" => null, "codeDiscount" => [ "code" => "...
Wakil Ahmed's user avatar
  • 1,467
1 vote
1 answer
306 views

How can I declare an associative array with something like declare -A ENV_JOBS=( [""]="" ["staging"]="staging-job-name ["dev"]="dev-job-name" ) ...
Yen's user avatar
  • 617
0 votes
0 answers
75 views

I have smarty 4.3 and php 8.1. I have this php array: array(4) { ["username"]=> string(16) "[email protected]" ["realname"]=> string(4) "blah" [&...
raphael75's user avatar
  • 3,268
1 vote
1 answer
724 views

For example // test.sv class cls; int b; endclass module m cls testObj; int map[cls]; initial begin inst = new; inst.b = 10; map[cls] = 12; $VPIcall; end ...
tarik jhin's user avatar
1 vote
0 answers
30 views

I am working on project where I am uploading two excel files and able to get the files data in 2d associative arrays. I want to calculate the total of 2 rows if it exists only on array1 and not ...
Alex's user avatar
  • 29
0 votes
1 answer
39 views

<?php $array['a']['b']['c']['d'] = "foo"; $many = ['b']['c']; echo $array['a']$many['d']; ?> Is there any way to make this work? I have try with {} around but i cannot make it work. ...
Mario Boulanger's user avatar
1 vote
3 answers
3k views

Trying to create a dynamic set of Key-Value pairs through a series of for loops that basically pull from a JSON file to create a series of arrays that are then iterated through to define the key-value ...
Davis Sayer's user avatar
0 votes
3 answers
89 views

The array $digit now has data in this form : 'numbers' => array ( 0 => '1,2,3', ) But I need that array in the below shown form: 'numbers' => array ( 0 => 1, 1 => 2,...
M G's user avatar
  • 27
0 votes
2 answers
49 views

I'm trying to create an array that looks like below. $arr = array( 'post_type' => 'smart_contract', 'post_status' => 'publish', 'author' => $user_id, '...
ratib90486's user avatar
0 votes
2 answers
110 views

I am working on an api that requires a json script, but I am making it so I can use the api on my website. The issue I am stuck on and struggling to find an answer for is when the array is 'compiled'. ...
Ether0p12348's user avatar
0 votes
2 answers
821 views

I'd like to count occurrences of a pre-known set of chars in a string of text. My intuition is to create a std::map with those chars as values and values initialised at 0, like so: unordered_map<...
Daniel Maxwell's user avatar
1 vote
2 answers
2k views

int c[][$][int]; I am trying to understand memories in depth. I was just wondering whether a 3D dynamic array with queue and associative array is possible or not? I am able to make 2D dynamic array ...
xxxl_eet's user avatar
1 vote
1 answer
77 views

I have an array of people stored in a multidimensional associative array. Each person belongs to a place and each place belongs to a timezone. I set up my variable like this: interface ...
StevenTakata's user avatar
-2 votes
1 answer
51 views

Issue New to PHP, trying to parse the values of an associative array that is in a list in PHP. I come from a Pythonic background and am faced with refactoring a code I wrote in Python to a PHP CLI ...
Terry Brooks Jr's user avatar
0 votes
2 answers
92 views

I need to implement a javascript fx to merge associative array that may have a non defined structure. I mean that sometimes i need to merge [ { name: 'Stefano', age:46 }, { name: 'Name2', age:...
Stefano Radaelli's user avatar
1 vote
1 answer
201 views

I am working on a php script to parse the movie nfo and tv nfo files that kodi generates/uses. However I have problems with getting some of the children properties (not sure if this is the correct ...
crosenblum's user avatar
  • 1,947
2 votes
1 answer
389 views

I want to have a global associative array, that is filled at several locations and I can not get it to work to initialize the array with the content of a string without using the declare -A -g over ...
roediGERhard's user avatar

1
2 3 4 5
67