multidimensional-array

CakePHP function to convert dotted arrays to multidimensional

In CakePHP, it seems like a lot of functions can take their arguments as nested, multidimensional arrays, or as dotted strings: $this->MyModel->contain(array( 'Something', 'Something.Else', 'Something.Else.Entirely' )); $this->MyModel->contain(array( 'Something' => array( 'Else' => 'Entirely' ) )); Therefore, I fig...

Putting array of arrays into a spring context

I just found a TestNG test case that uses Spring to provide its data source. As a result the code is quite clean and concise. However, I need to expand the test cases so they can take a variable list of inputs. Am I stuck using bean references for the list of lists as I've attempted below? Is there a way to do that and still be prett...

Recursive php function that turns nested array into nested html blocks

Hi guys, I'm looking to write a recursive php function that would call a function to generate nested HTML blocks ( not necessarily only DIVs ). So for example, for the following array: $a = array( 'b' => 'b value', 'c' => 'c value', 'd' => array( 'd1' => array( 'd12' = 'd12 value' ), 'd2' => 'd2 value' ), 'e' => 'e valu...

Why is the table filled with Array[0], Array[1],Array[2],Array[3] after the following SQL statement is executed?

Why is the table filled with Array[0], Array[1], Array[2], Array[3] after the following SQL statement is executed? mysql_query("INSERT INTO choicetable (announcementid, question, option1, option2, option3, option4) VALUES ('$announcementid', '$choicequestion[$j]', '$option[$j][0]', '$option[$j][1]', '$option[$j][2]', '$option[$j][3...

Generate a two dimensional array via LINQ

I am trying to create a matrix of doubles, representing a correlation between entities. Here's how I'm doing it via LINQ double[][] correlationsRaw = (from e in entitiesInOrder select (from f in entitiesInOrder select correlations.GetCorr...

What is the appropriate data structure for this array in CSharp?

Hey guys, If I've got this data structure in PHP, what data structure is the best for it in C#? $array = Array( [dummy1] => Array ( [0] => "dffas", [1] => "asdas2", [2] => "asdasda" ), [dummy2] => Array ( [0] => "asdasd", [1] => "sdfsdfs",...

Fashioning n-Dimensional Arrays in PHP From HTML Form

I'd like to have a form's data arrive on the server ordered in a specific format as an array. Presently, I have the following form elements which may appear numerous times in my markup: ... <tr> <td><p>Friend's Name:</p></td> <td><p><input type="text" name="friends[name][]" /></p></td> <td><p>Friend's Email:</p></td> <td><p><inp...

PHP recurrsive function to add new element to each level of an multidimensional array

Hi guys, How is is possible, using PHP to add a new index to each 'level' of an multidimensional array? For instance, for the following array: $array = array( 'a' => 'a val', 'b' => array( 'ba' => 'ba value', 'bb' => array( 'bba' => 'bba value' ), 'bc' => 'bc value' ), 'c' =>...

Creating an instance of a php key-value pair without an array

I'm writing a recursive function to construct a multidimensional array. Basically, the problem is as follows: function build($term){ $children = array(); foreach ( $term->children() as $child ) { $children[] = build($child); } if(!count($children)){ return $term->text(); } else { return $...

Multi-Dimensional Container in Java

I searched around on Google, but I was unable to find any libraries for a multi-dimensional container in Java (preferably one that supports generics as well). I could easily write one (in fact, I have started to), but I was hoping that I would be able to reuse the work someone else has done for the sake of efficiency. I don't necessari...

How do you add an array to another array in Ruby and not end up with a multi-dimensional result?

somearray = ["some", "thing"] anotherarray = ["another", "thing"] somearray.push(anotherarray.flatten!) I expected ["some","thing","another","thing"] ...

How to remove a row in two-dimensional array

I have a simple array, sort of like this 1 2 3 4 5 6 7 8 9 6 2 7 2 9 6 8 10 5 2 6 4 7 8 4 3 2 5 9 8 7 5 9 7 4 1 10 5 3 6 8 2 7 3 7 2 So, let's call this matrix[5][9]. I wish to now remove every row within this matrix that contains a certain value, in this case 10, so I am left with... 1 2 3 4 5 6 7 8 9 2 6 4 7 8 4 3 2 5 5 3 6 8 2 7 3...

How is memory allocated for a static multi-dimensional array?

All, This has been bugging me for a while now. In C\C++( i guess java and .NET as well) we do not have to specify the row index in a multi-dimensional array. So, for example i can declare an array of ints as such: int Array[][100]; I think static arrays in general are represented as contiguous memory on the stack. So, taking a column...

What is wrong with this c code?

Hello there, I'm trying to replace the first line with spaces, what is it that is wrong here? #include <stdio.h> int main(void){ char text[5][10]={ {'a','a','a','a','a','a','a','a','a','\0'}, {'a','a','a','a','a','a','a','a','a','\0'}, {'a','a','a','a','a','a','a','a','a','\0'}, {'a','a','a','a','a','...

Check for two adjacent bits in 2D array (Java)

I am writing a tic-tac-toe game in Java. I have a 2D array representing a 3-by-3 grid, and need a method to check if there are 2 bits set in such a way that a row of 3 can be formed by adding a third bit. The only way I could think of doing this is to iterate along the rows, checking for a blank space, then checking the bits around it,...

Extracting timings from a multidimensional array and writing to a file in c

Hello, I'm having trouble extracting the timings from a .srt (subtitle) file and writing it to another file called output.srt. When i run the following i get some funky stuff written onto the output file. // where hr=hours,mn=minutes,sc=seconds,ms=mili seconds #include <stdio.h> #define LINES 50 #define CHARAC 80 int main(void){ FI...

Bubble-Sort with 2D Array

Howdy, I do know how to implement a simple bubble-sort for 1dimensional array. But with 2dimensional or multidimensional, that's where I have my problems. So far I've been using this to sort 1Dimensional Arrays, works like a charm. But mostly with integer numbers, not strings: boolean sort; do{ sort = true; for (int i = 0; i < test...

Bind a multi-dimensional ArrayList to a Gridview

I have a DataGrid of seats available, each with a checkbox to be able to reserve the seat. In the button click event, if the CheckBox is clicked, I am adding the contents of the row to an ArrayList, then adding the ArrayList to a session before redirecting to the confirmation page: protected void Reserve_Click(object sender, EventArgs e...

php multi-dimensional array remove duplicate

Not sure if this question is a duplicate in need of removal, but I couldn't find the answer elsewhere so I'll have a go at asking. I've got a 2d array that looks as follows: Array ( [0] => Array ( [0] => dave [1] => jones [2] => [email protected] ) [1] => Array ( [0] => john [1] => jones ...

Dynamically setting value on array of pointers to integers

I have a multidimentional array of pointers to integer (of unknown rank) being passed into my function as such: public unsafe static void MyMethod(Array source, ...) { //... } Multidimensional arrays of pointers are being constructed outside of the method and being passed in. Here's an example: int*[,,,] testArra...