multidimensional-array

Convert List<double[]> to double[,]

Say I have a List<double[]> x = new List<double[]>(); double[] item = new double[] {1.0,2.0,3.0}; x.add(item); etc... Is there a faster/cleaner way to get this into a double[,] then looping it: double[,] arr = new double[x.Count,3]; for (row = 0; row < x.Count; row++) { for (col = 0; col < 3; col++) arr[row,col...

print element of array within array

hi this is my array structure. i want to print title track id . Array ( [@attributes] => Array ( [type] => array ) [track] => SimpleXMLElement Object ( [id] => 3617316 [created-at] => 2010-06-24T09:09:23Z [user-id] => 1219873 [p...

PHP: get keys of independent arrays

Hello. I have two arrays. Example of the first array: $arrayOne = array ( 'fruit' => array( 'apples' => array(), 'oranges' => array(), 'bananas' => array() ), 'vegetables' => array( 'tomatoes' => array(), 'carrots' => array(), 'celery' => array(), 'beets' => array ...

Creating Arrays from a plist file in iphone SDK 3.3 and up : objective c

Hello everyone. I have run into this issue and have put some major time into finding the answer. I am somewhat new to objective c but not to programming. Here is my question. I have a plist file with this structure root { A ( {songTitle : contents of song}, {songTitle : contents of song} ), B ( {songTitle ...

How do I sort a multidimensional array depending on it's items array keys and values?

Hi there. I have an array of permissions: array( array( "controller" => "somewhere", "action" => "", "namespace" => "admin", "method" => "GET" ), array( "controller" => "somewhere", "action" => "index", "namespace" => "admin", "method" => "" ), array( "controller" => "somewhere", "action" => "index", "namespace" => "admin"...

Two dimensional arrays allocation problem

Hello all, this is an interview question my friend was asked yesterday. The question was something like: will this program crash with an "access violation" error or not? I looked at it for a while and thought no, it won't. But actually trying this out in visual studio proved me wrong. I cannot figure out what happens here... or to be mo...

How can I return a specific array using an index in a multi-dimensional array in .NET?

I thought this was straight forward, but given a multi-dimensional array string[,] table = new string[,] { {"Apple", "Banana", "Clementine", "Damson"}, {"Elderberry", "Fig", "Grape", "Huckleberry"}, {"Indian Prune", "Jujube", "Kiwi", "Lime"} }; How can I return a specific ar...

android: how to merge an array of bitmap together in one bitmap ?

hi there, i'm trying to make a map loader for tiled, on android.. so far i could parse the tmx file, grab all the tile data, and put them in a 2dimensional array, like this: Bitmap tiles[x][y] ... it works and i can render tiled maps on android now, but only by interating through that tiles[][] array, like shown below.. how can i merg...

PHP: find key position in multidimensional array

Possible Duplicate: PHP: get keys of independent arrays Hello. I have a multi-dimensional array. I want a function that finds the position of the given array key (all my array keys are strings) and then returns the position of the key as an array. E.g: $arr = array ( 'fruit' => array( 'apples' => array(), ...

Using a mysql_query result in another query

Below are the queries I am executing. But for some reason $MachineQuery is not getting a result. I assume it has something to do with using $q1 in the query but I don't know why. Any Ideas? $q1 =mysql_query("SELECT DISTINCT SymptomID FROM Tree WHERE SymptomID NOT IN (SELECT DISTINCT SymptomID FROM Tree ...

PHP accessing a property of an object

Hi There, I have an object that looks like this when outputted via a print_r Array ( [178] => My_Model_Category Object ( [autoGenerateURLNameIfNotSupplied] => 1 [id] => 178 [name] => Just for Kids [date_created] => 2010-04-06 16:08:40 [last_updated] =...

malloc in C, but use multi-dimensional array syntax

Is there any way to malloc a large array, but refer to it with 2D syntax? I want something like: int *memory = (int *)malloc(sizeof(int)*400*200); int MAGICVAR = ...; MAGICVAR[20][10] = 3; //sets the (200*20 + 10)th element UPDATE: This was important to mention: I just want to have one contiguous block of memory. I just don't want to...

2D array in PHP

how can I store $result value in a 2d array. here my code- $sql="SELECT a.userId, b.name, b.dob FROM tbltree a INNER JOIN tblprofile b ON a.userId = b.userId WHERE a.superId ='$uid'"; $result=mysql_query($sql,$link)or die(mysql_error()); 2d array having three columns-userId | name | dob ...

Is auto-initialization of multi-dimensional hash array possible in Ruby, as it is in PHP?

I am so used to work in PHP with multi-dimensional arrays, where I can assign and initialize a hash by unset($a); // just to show that there is no variable $a $a['settings']['system']['memory'] = '1 Gb'; $a['settings']['system']['disk space'] = '100 Gb'; Is there a way to do similar thing in Ruby? Or I need to initialize all dimension...

Creating and using multi-dimensional array in php

$breakfast = array( 'rest_id' => $rest_id , 'type' => 'Breakfast' , 'value' => $bprice ); $lunch = array( 'rest_id' => $rest_id , ...

$_POST values from a the second dimension of an array

Using PHP. I'm trying to retrieve $_POST values from a the second dimension of a two dimensional $_POST array without actually knowing the names of the values being posted. Here is what I have; it doesn't work. foreach($_POST as $k=>$v) { $$k=$v; if (is_array($k) == true) { foreach($k as $value) { echo $v...

PHP: dynamically find key position in multidimensional array

I have already posted a similiar question to this one some time ago, but now it's different, so please don't close this as a duplicate. I have a multi-dimensional array. I want a function that finds the position of the given array key (all my array keys are strings) and then returns the position of the key in the array, AS an array. He...

Generating Combinations in python

I am not sure how to go about this in Python, if its even possible. What I need to do is create an array (or a matrix, or vector?) from 3 separate arrays. Each array as 4 elements as such, they return this: Class1 = [1,2,3,4] Class2 = [1,2,3,4] Class3 = [1,2,3,4] Now what I would like to do is return all possible combinations of thes...

Smarty: multidimensional array

I need to loop into a multidimensional array in smarty and {section} is giving me a hard time This is the array called $brands: Array (26) A => Array (4) 0 => "Alienation" 1 => "Alligator" 2 => "Amoeba" 3 => "Animal" B => Array (2) 0 => "Bell" 1 => "Bontrager" C => Array (9) 0 => "C...

On Passing a 2D-Array into a function.

This is not so much a question on, "How do I pass it into the function?" but rather, "Is this acceptable?" void func( int **ptr ); int main( int argc, char* argv[] ) { int arr[][3] = {{1, 2,}, {3, 4}, {5, 6}}; int *pArr = *arr; (&pArr[0])[1] = 3; func(&pArr); cin.get(); return 0; } void func( int **ptr ) { ...