3,316 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
4
votes
4
answers
109
views
Map unknown associative array element
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" &...
2
votes
1
answer
82
views
Downside of NOT using quotes for keys of associative array?
Every example I have found tends to go aa["key"]="value" and even with constants, e.g.:
declare -rA aa=( ["lit1"]="value1" ["lit2"]="value2" ...
-1
votes
2
answers
215
views
How to deserialize ${aa[@]@K} into referenced associative array with no eval effect?
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 ...
0
votes
2
answers
86
views
Create associative multidimensional array in a loop Python
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 ...
1
vote
1
answer
86
views
Displaying individual rows with same key as part of larger associative array using PHP and HTML
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 ...
1
vote
1
answer
183
views
Why isn't PHPStan complaining about invalid array keys?
Here's the code:
<?php declare(strict_types=1);
/**
* @param array{key?: string} $options
*/
function hello($options)
{
var_dump($options);
}
hello([
'WRONG_KEY' => '...',
]);
I ...
3
votes
2
answers
199
views
What kind of implementation can I use for a static associative array on a vintage system with very limited resources?
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 ...
-7
votes
2
answers
91
views
Filter an array of arrays to remove rows where the entire payload is found inside another (potentially larger) row [closed]
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 =>...
-4
votes
1
answer
138
views
Building nested array with foreach [closed]
I am trying to build an associative multidimensional array like this:
array(
[0] => Array(
Parent => Mr Smith,
Children => array(
Firstmane => Bob,
...
1
vote
1
answer
209
views
add JSON object keys and values to bash associative array
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":...
0
votes
2
answers
79
views
Global associative array (hash) in the older bash-4
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
...
-1
votes
1
answer
73
views
How to dynamically convert a string into (and revert from) UTF8 special font characters?
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!');...
1
vote
3
answers
117
views
Dlang associative array of an array of strings keyed by a string has unexpected behavior
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 ...
-1
votes
1
answer
52
views
bash syntax for accessing an associative array with a value from a different associative array
Good morning,
I have here:
declare A- accocArray1=(["a01"]=1 ["a02"]=2 ["a03"]=3)
declare A- accocArray2=(["b01"]=1 ["b02"]=2 ["b03"]=3)
...
1
vote
4
answers
114
views
Use flat array's values to generate an associative array whose keys and values are given a static prefix
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)
);
...