Tagged Questions
28
votes
5answers
51k views
Multi-dimensional associative arrays in javascript
There is the following query results: (key1 and key2 could be any text)
id key1 key2 value
1 fred apple 2
2 mary orange 10
3 fred banana 7
4 fred orange ...
7
votes
3answers
25k views
PHP combine two associative arrays into one array
$array1 = array("$name1" => "$id1");
$array2 = array("$name2" => "$id2", "$name3" => "$id3");
I need a new array combining all together, i.e. it would be
$array3 = array("$name1" => ...
6
votes
2answers
12k views
BASH: need some help with multidimensional associative arrays
I'm trying to create a multidimensional associative array but need some help. I have reviewed the page suggested in this SO answer but it confused me even more. So far here is what I have:
The ...
6
votes
6answers
3k views
C# 4.0 - Multidimensional Associative Array (or way to mimic one?)
I'm an experienced PHP developer transitioning to C#. At present I am working on a Windows Forms application.
I found in my searches that C# doesn't support associative arrays in the same loose ...
5
votes
4answers
242 views
re arrange php associative array
I have an array:
$example = array();
$example ['one'] = array('first' => 'blue',
'second' => 'red');
$example ['two'] = array('third' => 'purple',
...
4
votes
2answers
2k views
PHP:: array_unique for arrays inside array
I need like array_unique for arrays inside array.
The Case - should be equal, but output "not equal":
<?php
$arr=array(array('a',1),array('a',2));
$arr2=array_unique($arr);
if($arr2==$arr){
...
4
votes
2answers
9k views
How to insert a new key value pair in array in php?
I've an array as follows named $test_package_data. For the reference I'm printing first two elements of it:
Array
(
[0] => Array
(
[test_pack_id] => ...
4
votes
2answers
5k views
Storing PHP Arrays in Wordpress User Meta Database
This should be easy for a PHP expert. I am having trouble storing and pulling arrays in Wordpress through the update_user_meta function.
So I have an associative array built like so:
Array
(
...
4
votes
2answers
54 views
How to manipulate the array in following scenario?
I've have an array called $data. Actually it's a quite big array and it gets generated dynamically. That means it could be small or large. But for your reference I'm printing out a relatively small ...
4
votes
2answers
2k views
Create PHP multidimension associative array from MySQL linked tables SELECT query
I'm hoping someone could help me with this problem.
Say I have 3 DB tables:
Users:
user_id, user_name
100, John
101, Jessica
Cars:
car_id, car_name
30, Corvette
31, BMW
UsersCars:
user_id, ...
3
votes
2answers
95 views
How to access the values from inner key of associative array in PHP?
Following is may multidimensional array named $form_data:
Array
(
[form_submitted] => yes
[teacher_id] => 3807f31f8c4357bbb56662047529dcde
[cs_map_ids] => Array
(
...
3
votes
2answers
28 views
Why I'm not able to add new key value pair in an associative array?
I've a large associative array titled $data. For your understanding I'm printing below one element from it.
Array
(
[0] => Array
(
[id] => 92
[zip_code] ...
2
votes
2answers
3k views
php session variable multidimensional associative array issue
I've looked around SO, but can't find an explanation to what is going on in my $_SESSION variables.
@ob_start();
$k=@ob_get_contents();
@ob_end_clean();
@session_start();
unset($s,$m);
$m1 = ...
2
votes
1answer
6k views
Creating a Multidimensional, Associative Array in VBScript
Is it possible to create a multidimensional, associative array in VBScript?
I'm trying to recreate the following JScript code in VBScript:
names["teachers"] = ["Helen","Judy","Carol"];
...
2
votes
3answers
72 views
How to change the value of an specific associative array in PHP?
I've a dynamically generated very huge array called $test_package_data. For your understanding I'm giving below the contents of array $test_package_data.
Now what I want to achieve is convert the ...
2
votes
4answers
557 views
What's the simplest way to check that values aren't empty in 2D array?
For example, I have an array like this:
array(4) ( "a" => string(0) "" "b" => string(0) "" "c" => string(0) "" "d" => string(0) "" )
None of given values should be empty.
At the moment, I use ...
2
votes
4answers
1k views
Sort an associative array in php with multiple condition
Consider following array
$details = array(
array('lname'=>'A', 'fname'=>'P','membkey'=>700,'head'=>'y'),
array('lname'=>'B', 'fname'=>'Q','membkey'=>540,'head'=>'n'),
...
2
votes
2answers
1k views
PHP Associative array sort
I have an array like one below.
Currently it is sorted alphabetically by the OwnerNickName field.
Now i want to brig the array entry with OwnerNickName 'My House' as the first entry of the array and ...
2
votes
3answers
737 views
How to remove empty associative array entries
I have an associative array: $csv_arr
Array
(
[0] => Array
(
[Enfalac] => alpha linolenic acid 300 mg
[Enfapro] => alpha linolenic acid 200 mg
)
...
2
votes
3answers
362 views
multidimensional array
Is there a way to access a multidimensional array from any position? example:
$arr = array (
1 => array ( 1, 'some-url-one', 'Some Title One' ),
2 => array ( 2, 'some-url-two', 'Some ...
2
votes
3answers
1k views
Using array_diff_assoc function in PHP
Hello I have two nested arrays and need to find the difference between the reference array and the data array. I am using array_dif_assoc function, and am unable to get the right difference, I am not ...
2
votes
2answers
185 views
Arranging a multi-dimensional array
I have a PHP array that looks like this: http://pastie.org/1346063 (see pastie for array example)
What I want to do is re-sort that array into another array that is sorted by each array's ...
2
votes
1answer
43 views
Why I'm not getting the updated array in following scenario?
I'm having an array named $questions as follows:
Array
(
[0] => Array
(
[question_id] => 33185
[question_parent_id] => 0
[question_subject_id] ...
2
votes
2answers
817 views
PHP Subtract values in Array 1 from values Array 2
So I would like to subtract stocks from $array1 and quantity from $array2,
$array1= ([product_id]=>4, [stocks]=>20)
$array2= ([product_id]=>4, [quantity]=>3)
So that would be:
$array1= ...
2
votes
4answers
368 views
Create new multidimensional Associative array from 2 arrays
I am looking for a solution to create a single multidimensional associate array in javascript.
What I have: I have a mysql database I am accessing with php and have an array containing all fields ...
2
votes
2answers
355 views
Push Associate array into another array
I would like to push an associate array into another array but I an not sure how to go about it. At the minute I have the following:
$rate_info = array(
"hotel_rating" => ...
2
votes
1answer
778 views
get count of array in multidimensional associative array
I'm trying to determine the count of each array within a multidimensional associative array. For example, if I have an array like:
Array
(
[food] => Array
(
[soup] => ...
1
vote
3answers
533 views
Implementing multidimensional associative arrays in Common Lisp
I'm looking for the best way to implement multidimensional associative arrays in Common Lisp. I'm using SBCL.
For example in MATLAB, I can create a struct array like this, eg. with some geographical ...
1
vote
4answers
793 views
PHP multidimensional array sort & delete rows
I have a PHP multidimensional associative array with the following structure:
Fields: TYPE - COLOUR - SIZE - PRICE
[0] - rose, var2, var3, price
[1] - rose, var2, var3, price
[2] - daffodil, var2, ...
1
vote
2answers
710 views
PHP - Automatically creating a multi-dimensional array
So here's the input:
$in['a--b--c--d'] = 'value';
And the desired output:
$out['a']['b']['c']['d'] = 'value';
Any ideas? I've tried the following code without any luck...
$in['a--b--c--d'] = ...
1
vote
2answers
577 views
Sum of multidimensional associative array PHP
Array
(
[Sum_1] => Array
(
[0] => Array
(
[e] => 1000001
[u] ...
1
vote
3answers
2k views
How do I create multidimensional and associative arrays in javascript?
In my PHP-script I have a multidimensional and associative array I want to "transform" into a javascript array. The array looks like this in PHP:
<?php
$myArray = array(
array( "value" ...
1
vote
2answers
456 views
php compare/match range of values
I have an array to which I need to compare data from mysql. Usually I'm doing a straight comparison so I can do an if ($array[$i]===$mysql[$i]), but I do have one instance where I need to match it ...
1
vote
3answers
4k views
Looping through a multidimensional associative array
I've been making an IRC bot in PHP. I've given different users specific access levels between 0 and 5. 0 being a guest and 5 being an admin.
I've been trying to write a command that when a user ...
1
vote
4answers
2k views
How to create a 2D map in Java?
I would like to have a mapping which maps two string into one string. For example: map["MainServer","Status"] return "active". What is the best way to do it in Java. Should I use HashMap which include ...
1
vote
4answers
578 views
Sorting a value pair in Javascript
I must be missing the proper term or else I'm sure I could find the answer by searching... in any case, here's what I want to do.
Through javascript, I get four variables (A, B, C, and D) that I ...
1
vote
2answers
334 views
multidimensional array - adding a key and value where a key and value is matched
I'm trying to add a key and value (associative) from an array to another array, where one specific key and value match. Here are the two arrays:
$array1 = array(
1 => array(
...
1
vote
4answers
146 views
PHP remove similar arrays based on several associations in an associative array
I have this type of associative array.
Array
(
[0] => Array
(
[bookedArea] => Comp Pool
[laneBooked] => 1
[paidBy] => Edmonton Aurora Synchronized Swim Club
...
1
vote
2answers
157 views
How to propagate a current menu item flag upwards in a multidimensional array?
I have a menu being built via a multi-dimensional array. A current item is set by matching its url attribute with the current request. I want this value to bubble up to its parents, but I can't for ...
1
vote
2answers
254 views
assign object to array in javascript multidimensional array
Below i have given my code which is a javascript function which calls a php file and gets json data .... all things are perfect yet but i am getting problem when i want to adda data to a ...
1
vote
3answers
206 views
need efficient restructuring of a complicated PHP assoc array [closed]
In my data mining project, I'm given a complicated, huge multidemensional array of arrays that contains all the info I require, except that I have to perform a "fix" on it before I can process it. ...
1
vote
2answers
2k views
How to loop through multidimensional associative javascript array?
I have 'multidimensional associative' javascript array (which in fact is object with properties as JS can't have native associative array):
var multiArray={ AAA:"one", BBB:"two", CCC:{ 0:"xxx", ...
1
vote
2answers
516 views
Find value of key where value of another key equals matched value (associative array)
For example, I have an array of:
array(
array(
['make']=>ford
['color']=>blue
['type']=>automatic
),
array(
['make']=>chevrolet
...
1
vote
1answer
47 views
Why I'm getting a warning as “Warning: Illegal offset type in abc.php”?
I'm converting one array into another array by changing some key names, by creating new array keys, etc. In the code I tried I'm getting following warning multiple times(i.e. the indication that loop ...
1
vote
2answers
44 views
How to create an associative array in following case?
I'm having few arrays as follows. Actually I'm having too many such arrays but for your reference I've printed only few of them:
Array
(
[0] => lineItemData
[1] => name
)
Array
(
...
1
vote
1answer
571 views
How to pass a multidimensional associative array in URL
I have been Googling for hours but I can't make heads nor tails out of it. I have a multidimensional associative array like this:
$mArray = array(
array("m" => "0"),
array("m" => "1"),
...
1
vote
4answers
491 views
php, mysql - Combine result into multidimension associate array
I have the following MySQL database :
| id | sessionId | time |
|------------|-------------|---------------------|
| 54 | 4 | 2013-03-23 ...
1
vote
2answers
85 views
Associative subarrays in Javascript
How can the equivalent in PHP be done in JS?:
$this->gridColumnData[] = array('field' => 'id', 'width' => 50, 'title' => 'Enquiry Id') ;
$this->gridColumnData[] = array('field' => ...
1
vote
2answers
749 views
PHP - Convert multidimensional associative array's key strings into numbers
I have a multidimensional associative array like this:
$type = Array(
[unit-1] = Array(
[taxon-1] = Array(
[0] = Array(
[a] = 1,
[b] = 1,
[c] = 'string1'
),
...
1
vote
3answers
139 views
PHP: Building array out of values of another, associative, multidimensional array
I have an array, let's call it $menus, that contains something like this:
Array(
[Main] => Array (
[menu_name] => Main
[title] => Main Menu
)
[Nav] => Array (
...