associative-array Questions
6
Solved
I have a string like this:
key=value, key2=value2
and I would like to parse it into something like this:
array(
"key" => "value",
"key2" => "value2"...
Basilisk asked 7/2, 2011 at 16:51
7
Solved
I have a function called insert which takes two parameters (name and telnumber).
When I call this function I want to add to an associative array.
So for example, when I do the following:
insert(&qu...
Orderly asked 30/11, 2011 at 15:35
16
Solved
What is the equivalent of Python dictionaries but in Bash (should work across OS X and Linux).
Tombac asked 29/9, 2009 at 18:29
8
Solved
I understand that there are no associative arrays in JavaScript, only objects.
However I can create an array with string keys using bracket notation like this:
var myArray = [];
myArray['a'] = 200;...
Tricho asked 29/5, 2016 at 23:41
1
Solved
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: na...
Stuck asked 11/1 at 13:10
4
Solved
I have a multidimensional array:
$template = Array (
[0] => Array ( [id] => 352 [name] => a )
[1] => Array ( [id] => 438 [name] => b )
[2] => Array ( [id] => 351 [name]...
Hurdle asked 19/6, 2017 at 10:47
6
Solved
//go through each question
foreach($file_data as $value) {
//separate the string by pipes and place in variables
list($category, $question) = explode('|', $value);
//place in assoc array
$data...
Eustis asked 21/3, 2011 at 23:11
2
Can bash associative arrays be initialized in a (...) list similarly to non associative arrays? Format?
Updating to give an answer using the comments.
Yes, the format depends on the version of bash...
Sightread asked 17/2, 2022 at 17:11
3
I'm using the schema library.
How can I create a schema to validate if a dictionary contains anyone of the keys and corresponding values in it?
mydict_schema = Schema({
Optional('name'): str,
O...
Lehrer asked 27/7, 2017 at 9:16
6
I have an array such as ['id' => 1, 'name' => 'Fred'].
I want to call array_map on this array and also use the key inside the function. However, when I make a return, my keys will become inde...
Gipon asked 26/8, 2014 at 19:4
10
Solved
Say I have an array like this:
array(2) {
[0]=> array(2) {
["n"]=> string(4) "john"
["l"]=> string(3) "red"
}
[1]=> array(2) {
["n"]=> string(5) "nicel"
["l"]=> stri...
Crowboot asked 5/11, 2012 at 13:46
5
Solved
Let S be an associative array in PHP, I need to retrieve and extract from it the first element, both the value and the key.
I would use
value1=array_pop(S);
but it only gives me the value.
I ...
Trutko asked 7/7, 2011 at 10:9
11
Solved
I have two arrays like this:
array(
'11' => '11',
'22' => '22',
'33' => '33',
'44' => '44'
);
array(
'44' => '44',
'55' => '55',
'66' => '66',
'77' => '77'
);
I want t...
Lashkar asked 30/6, 2011 at 13:24
11
Solved
I'm looking for a fast way to turn an associative array in to a string. Typical structure would be like a URL query string but with customizable separators so I can use '&' for xhtml links ...
Dunlap asked 2/1, 2009 at 21:6
3
Solved
I'm confusing array_diff behavior
why genre don't exist on diff array?
Do you know how to resolve the matter?
-code
<?php
$array1 = array
(
'value01' => '0',
'value02' => 'v2',
'genre' ...
Electrophorus asked 20/1, 2011 at 0:47
8
Solved
I want to check whether the "user" key is present or not in the session hash. How can I do this?
Note that I don't want to check whether the key's value is nil or not. I just want to check whether...
Territorialism asked 24/12, 2010 at 22:2
4
Solved
PHP's native sorting functions modify by reference and do not return the sorted array.
I am looking for a reliable standard method to sort an array, returning the sorted array as the return value.
...
Rennarennane asked 10/9, 2013 at 13:45
7
Solved
I have an array of subarrays in the following format:
[
'a' => ['id' => 20, 'name' => 'chimpanzee'],
'b' => ['id' => 40, 'name' => 'meeting'],
'c' => ['id' => 20, 'name' ...
Brandiebrandise asked 27/9, 2011 at 19:49
7
Solved
Does anyone know of an elegant way to combine two associative arrays in bash just like you would a normal array? Here's what I'm talking about:
In bash you can combine two normal arrays as follows...
August asked 22/4, 2015 at 17:29
10
Solved
All the documentation I've found so far is to update keys that are already created:
arr['key'] = val;
I have a string like this: " name = oscar "
And I want to end up with something li...
Fenton asked 9/12, 2008 at 1:13
8
Solved
How can I conditionally add 'b' => 'xyz' in the array below, in the array() statement?
$arr = array('a' => abc)
The ternary operator doesn't let me do it.
Mailand asked 25/6, 2011 at 13:7
2
Solved
$var is an array:
Array (
[0] => stdClass Object ( [ID] => 113 [title] => text )
[1] => stdClass Object ( [ID] => 114 [title] => text text text )
[2] => stdClass Object ( [...
Meanie asked 6/8, 2010 at 15:7
11
When I create a new JavaScript array, and use an integer as a key, each element of that array up to the integer is created as undefined.
For example:
var test = new Array();
test[2300] = 'Some stri...
Tipster asked 4/1, 2010 at 23:3
4
Solved
I use several associative arrays in my PHP application and I'm using PHP documentor to comment my sources. I never really did specify comments for the arrays in an array, but now I need to do that ...
Exine asked 26/4, 2010 at 13:21
6
Solved
Is it possible to prepend an associative array with literal key=>value pairs? I know that array_unshift() works with numerical keys, but I'm hoping for something that will work with literal keys.
...
Trinitrobenzene asked 3/9, 2009 at 1:28
1 Next >
© 2022 - 2024 — McMap. All rights reserved.