multidimensional-array

Is there a simple way to duplicate a multi-dimensional array in Ruby?

I have a 2-dimensional array in Ruby that I want to produce a working duplicate of. Obviously I can't do this; array=[[3,4],[5,9],[10,2],[11,3]] temp_array=array as any modifications I make to temp_array will also be made to array, as I have merely copied the object identifier. I thought I would be able to get around this by simply us...

Sorting multidimensional array in PHP

Hi guys, I am currently creating a sorting method that consists of values from an mysql query. Here's a brief view of the array: Array ( [0] => Array ( ['id'] = 1; ['countries'] = 'EN,CH,SP'; ) [1] => Array ( ['id'] = 2; ...

Javascript multidimensional object with unexpected properties

Working in javascipt, I'm initialising a multi dimensional object (which itself is nested several Objects deep). However, when looking at the properties of the child object it has unexpected properties, the first one being "fromBase64". This happens when using the IE6 browser and the TIBCO GI framework, but the object is independent of a...

php Multidimensional Array pushing

Is it possible to array_push to a multidimensional array? Creating the array using: $ObjectArray = array(); $ShiftArray = array($ObjectArray); $WeekShiftArray = array($ShiftArray); $MasterShiftArray = array($WeekShiftArray); And trying to push to the array using array_push($MasterShiftArray[$last_monday_from_date][$CurrentShift->O...

Set rank of array at runtime

Hi, I was wondering what the simplest way would be to implement an array who's rank is specified at runtime. The example I am working on stores a array of boolean values for lattice points, and I want the user to be able to chose how many spatial dimensions the model uses at runtime. I've looked at the Array.newInstance() method: dim...

Objective-C accessing / changing array elements in a multidimensional array (NSArray)

I'm trying to change a value in a multidimensional array but getting a compiler error: warning: passing argument 2 of 'setValue:forKey:' makes pointer from integer without a cast This is my content array: NSArray *tableContent = [[NSArray alloc] initWithObjects: [[NSArray alloc] initWithObjects:@"a",@"b",@"c",nil], ...

How do I reference multi-dimensional arrays?

I'm trying to understand multi-dimensional arrays in Java, but I think it applies to any language. Please consider this snippet I found on the web: //************************************ // static array initialization //************************************ byte[][] smallArray = { { 10, 11, 12,...

Does Prototype's Array.compact() filter recursively for multidimensional arrays?

I'm just wondering if Prototype's helper functions Array.compact() and Array.without() filter for multidimensional arrays. It doesn't look like it, and if so, was there a reason for this or is there another helper function in Prototype that does this? ...

Displaying multidimensional array in php...

Hi, I have an array like this: $tset = "MAIN_TEST_SET"; $gettc = "101"; $getbid = "b12"; $getresultsid = "4587879"; $users["$tset"] = array( "testcase"=>"$gettc", "buildid"=>"$getbid", "resultsid"=>"$getresultsid" ); Arrays in PHP is confusing me. I want to displ...

Sort multidimensional array of objects

I've had trouble with the examples in the PHP manual, so I'd like to ask this here... I have an array of objects.. Is there a way to sort it based on the contents of the object? For example, my array is: Array ( [0] => stdClass Object ( [id] => 123 [alias] => mike ) [1] => stdClass Obje...

SQL result to PHP multidimensional array

Hi, I'm retrieving some hierarchical data from an Oracle database using the "connect by" function. Then I populate a PHP array with the result of my query looking like: while ($row_branches = oci_fetch_array($query_tree)) { $tree[] = array( 'id' => $row_branches['ID'] , 'parent' => $row_branche['PARENT'] , 'data' => htm...

C# create 3x3 2d map with labels

Is there a way to create 3 rows with 3 colums with labels (or similar) to create a 2d "map" with data to manipulate in an easy way? just placing 9 labels is easy but I want each labels to be accessed with the same array. How it looks like in the form: label1 label2 label3 label4 label5 label6 label7 label8 label9 If i need to chang...

Pass by reference 2D dynamically allocated double array in C

Hi, I'm trying to convert my string into a dynamic array of doubles. Each space of my string represents a column, each ";" represents a new row. When this code runs, it only works for when *F[0][col]. When it gets to *F[1][col] it gives me the error "Unhandled exception at 0x00e4483c in CCode.exe: 0xC0000005: Access violation reading l...

search&replace array key using PHP and CakePHP Set Class

hi, i need to write function that searches & replaces key in multi-dimensional array in following manner: input array: [0] => Array ( [Foo] => sometext [Foo2] => Array ( [lorem] => 1 [Avatar2] => Array ( [meta_key] => avatar2 [...

Large VBScript array yields 'Out of Memory' error

In Classic ASP (VBScript), if I try to create a large 2-dimensinal array, I get an "Out of Memory" error. For example, this DIM xxx : xxx = 10000 DIM yyy : yyy = 10000 REDIM aaa(xxx, yyy) Response.End yeilds this Microsoft VBScript runtime error '800a0007' Out of memory Is their another data structure I can use that will work, o...

Database to return multi-dimensional result

This is a follow-up question to my previous one. Situation: Table 1: +--------------------+--------------------+ | v_id | v_name | +--------------------+--------------------+ | 1 | v_name1 | +--------------------+--------------------+ | etc... Table 2: +--------------------+--------...

Selecting k*k subarray from p*p*n array in Fortran

Hi, I have a p*p*n array in Fortran, and I want to extract k*k subarray from that bigger array. I tried like this, but not sure does it work: do i=1,p vp(i)=i end do help=y(1:p,t)*vp do t = 1, n A(1:k,1:k,t) = B(pack(help,help>0), pack(help,help>0), t) end do where y contains values 0 and 1, 1 meaning that row/column is wanted...

Sorting multi-dimentional array by more than one field.

Hi. I have the following data: Array ( [0] => Array ( [filename] => def [filesize] => 4096 [filemtime] => 1264683091 [is_dir] => 1 [is_file] => ) [1] => Array ( [filename] => abc [filesize] => 4096 [filemtime] => 1264683091 [is_dir] => 1 ...

What's the most elegant way to add up multidimensional arrays field by field in PHP?

I'm trying to add up two multidimensional arrays, both equally sized, field by field. I.e.: $sum[4][3] = $a[4][3] + $b[4][3]; Or: $a = array( array(1, 4), array(3, 2)); $b = array( array(9, 2), array(1, 0)); Should result in: $sum = array( array(10, 6), array(4, 2)); Is there a more elegant way than foreaching over all the array...

access array from struct in C

In my data.h file I have: typedef struct { double ***grid; } Solver; In my .c file I have static Solver _solver; which first makes a call to a function to do some allocation on grid such as _solver.grid = malloc(....); //then makes a call to GS_init(_solver.grid); The GS_init function is declared in GS.h as: void GS_init(...