multidimensional-array

PHP array : simple question about multidimensional array

Hello, i've got a SQL query which returns multiple rows, and i have : $data = array( "nom" => $row['nom'] , "prix" => $row['rapport'], "average" => "$moyenne_ge" ); which is perfect, but only if my query returns one row. i tried that : $data = array(); $data[$row['nom']]["nom"] = $row['nom'] ; ... $data[$row['nom'...

Android / Java rare and seemingly impossible exception causing force close

Hello all, I have an interesting problem being reported to me from an android application I have published. I have a two-dimensional array that I am iterating through using two for loops like so: for (int i = 0; i < arr.length; ++i) { for (int j = 0; j < arr[i].length; ++j) { if (arr[i][j] != 0) // does stuff...

Question regarding two dimensional array

I have some problems using two dimensional array in the code and need some help. static const int PATTERNS[20][4]; static void init_PATTERN() { // problem #1 int (&patterns)[20][4] = const_cast<int[20][4]>(PATTERNS); ... } extern void UsePattern(int a, const int** patterns, int patterns_size); // problem #2 UsePattern(10, ...

Looping through multidimensional array starting from second array in PHP, if exists

I am returning an SQL query from database using PEAR into an array. $db_results = $db->getAll("SELECT * FROM loans ORDER BY amount, length, true_interest_cost"); If the query return results, I would like to show the first result formatted in one way and then the rest of the results formatted another way. So, my end result would look ...

Understanding c-pointers for rows in 2-dimensional array

I have the following code: int main() { int n = 3, m = 4, a[n][m], i, j, (* p)[m] = a; for (i = 0; i < n; i++) for (j = 0; j < m; j++) a[i][j] = 1; p++; (*p)[2] = 9; return 0; } I have a hard time understanding what p is here, and the consequences of the operations on p in the end. Can someone g...

How to sort a multi-dimensional array by a 4th level value in PHP

I have an array which is converted from an XML response. What I need to do is sort the array ascending alphabetically using the 'COMPANY' value. I have attempted to use array_multisort, but I'm having no luck at all. Any help would be greatly appreciated. Here is the array: array(1) { ["DATASOURCE"]=> array(1) { ["MEMBER"]=> ...

Finding position of each word in a sub-array of a multidimensional array

I have an array: tokens = [["hello","world"],["hello","ruby"]] all_tokens = tokens.flatten.uniq # all_tokens=["hello","world","ruby"] Now I need to create two arrays corresponding to all_tokens, where the first array will contain the position of each word in sub-array of tokens. I.E Output: [[0,0],[1],[1]] # (w.r.t all_tokens) To m...

php transform array into multidim array

So I'm working on a website with Doctrine as ORM and I get the following array back as a result: Array ( [0] => Array ( [c_cat_id] => 1 [c_title] => Programas e projetos [p_menu] => PBA BR 163 [p_page_id] => 1 ) [1] => Array ( [c_cat_id] => 1 [c_title] => Programas e projetos ...

Newtonsoft.json throwing error: Array was not a one-dimensional array.

Hi everybody, I am getting an error when trying to serialize an object products. Product product = new Product(); product.Name = "Apple"; product.Expiry = new DateTime(2008, 12, 28); product.Price = 3.99M; product.Sizes = new string[3,2] { {"Small","40"}, {"Medium","44"}, {"Large","50"} }; string json = JsonConvert.SerializeObje...

Displaying multidimensional data in WPF

What is the best way to display multidimensional data in WPF? I won't know the size/shape of the data until runtime. Ideally I would like to use databinding but that is not a strict requirement. I was thinking some sort of grid but I don't know how to dynamically bind to the data and have it figure out the number of rows and columns. Sug...

Is it bad practice to use multi-dimensional arrays in C/C++?

Some programmers seem to violently hate them, while others seem to think they're fine. I know that anything that can be done to a multi-dimensional array can also be done to a regular array, so they're functionally equivalent. Is it bad practice to use multi-dimensional arrays, or does it not matter? ...

Howto transpose multidimensional array in place

how to transpose a 2D matrix in place? ...

Prototype.js: How can i return an array without all the methods Prototypes extends Array with?

Hi! Is there a way to return a new version of an array/hash that does not contain all the methods/functions that prototype extends the array object with? Example: var myArray = $A(); myArray['test'] = '1'; myArray['test2'] = '2'; var myVariableToPassToAjax = myArray; If I debug myVariableToPassToAjax it looks like this: Array ( ...

Processing multiple arrays simultaneously in ruby

I have an array : a=[[1,2],[3]] and b=[[2,3],[5]] i need to add corresponding elements in each array simultaneously in order to obtain the result; result=[[3,5],[8]]. Thanks and Cheers! ...

php foreach getting values from an array

I am having trouble accessing the values in an array, the array looks like this, Array ( [0] => Array ( [id] => 1661 [code] => 849651318 [job_status] => 4 [looking_for] => Lorem ipsum [keywords_education] => Derby University [sector_id_csv] => 10,21,9,...

Search for values in nested array

I have an array as follows array(2) { ["operator"] => array(2) { ["qty"] => int(2) ["id"] => int(251) } ["accessory209"] => array(2) { ["qty"] => int(1) ["id"] => int(209) } ["accessory211"] => array(2) { ["qty"] => int(1) ["id"] => int(211) } } I'm trying to find a way to verify an id value exists ...

[Java/Android] Multidimensional array to ListView.. how?

I have a query result set which I like to edit first and then put it to my ListView. Without editing my data first, I could use SimpleCursorAdapter like that: ListAdapter adapter = new SimpleCursorAdapter( this, R.layout.list_item, mCursor, new String[] { "address", "city" }, new int[] { R.id.address, R.id.zip_ci...

multi-dimension array value sorting in php

Another potentially interesting (or n00b, whatever comes first) question. I am building up an array with a set of database fields with information about table, actual field name and descriptive field name as a multi-dimensional array. Here is what it currently looks like: $Fields['User']['ID'] = "User ID"; $Fields['User']['FirstName'] ...

how to create dynamic two dimensional array in java?

i want to create two dimensional array dynamically.I know the number of columns.But the number of rows are changed dynamically.I try the array list,but it stores the value in single dimension only.what can i do? ...

Create an grid array...

Okay so I am looking to create a grided array in OGRE3D game engine but the array is generic my array skills are pretty basic and need work so I am posting this just to be sure I am doing this correctly. #define GRIDWIDTH 10 #define GRIDHEIGHT 10 int myGrid [HEIGHT][WIDTH]; int n,m; int main () { for (n=0;n<HEIGHT;n++) for (m=0;...