multidimensional-array

C++ multi-dimensional array initialization

Hey Guys, in C++ I want to initialize a double matrix (2-dimensional double array) like I would normally do without pointers like so: double data[4][4] = { 1.0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 }; However, since I want to return and pass it to functions, I need it as a double** pointer. So, basically I need to initia...

Create javascript 2D array of incremental values from 1 - 1000 and second value a random number from 1 - 50

Hi, I need to create a 2D array for some POC work. The first value of the array needs to go up in single increments between the values 1 to 1000 and the second value needs to be a random number from values 1 to 50. ...

Grabbing specific values from a multi-dimensional array in PHP

Hi there, I'm new to programming and I'm tackling arrays. I thought I had multi-dimensional arrays figured out but I guess I don't. Here's the code I'm working on: $loopcounter = 0; while ($myrow = mysql_fetch_array($results)) { //...other stuff happens... $allminmax[$loopcounter][] = array("$myrow[3]","$currentcoltype","$tempmin",...

Python: shape of a matrix and imshow()

Hello! I have a 3-D array ar. print shape(ar) # --> (81, 81, 256) I want to plot this array. fig = plt.figure() ax1 = fig.add_subplot(111) for i in arange(256): im1 = ax1.imshow(ar[:][:][i]) plt.draw() print i I get this error-message: im1 = ax1.imshow(ar[:][:][i]) IndexError: list index out of range Why do I g...

Adding items to a multi-dimensional array during query while loop

I have a query returning data that looks like this: Status Total Success 234 Failed 20 Missing 12 I want to add this to an array which can then be used to populate a google pie chart. the array would look like this: array backup = array("Success" => 234), ("Failed" => 20), ...

convert sub-arrays with only one value to a string

I have a multidimensional array, the sub-arrays consist of further values, I would like for all sub-arrays that only have one value to be converted into a string. How can I successfully scan through a multidimensional array to get the result? Below is a small section of the array as it is now. [1] => Array ( [name] => Array ...

PHP Dynamically adding dimensions to an array using for loop

Here is my dilemma and thank you in advance! I am trying to create a variable variable or something of the sort for a dynamic associative array and having a hell of a time figuring out how to do this. I am creating a file explorer so I am using the directories as the keys in the array. Example: I need to get this so I can assign it va...

How to convert a Navigablemap to String[][]

I need to convert a navigable map to a 2d String array.Below given is a code from an answer to one of my previous question. NavigableMap<Integer,String> map = new TreeMap<Integer, String>(); map.put(0, "Kid"); map.put(11, "Teens"); map.put(20, "Twenties"); map.put(30, "Thirties"); map.put(40, "Forties"); map.put(50, "Senior"); ...

Multi SQL Queries in associative array with PHP/SQL

I've got a very simple question about sending multi-queries with php/sql and add each result in an associative array. Basically, I've assigned each query in an associative array. Each result for each queries go into my multi-dimensional array $el['nameofthequery']['resultsofthequery'] //connection information $host = "localhost"; $u...

Is it possible to count the number of dimensions in an array?

I want to be able to know the level of an array as it is being built. The code loops through a bunch of directories to create a massive multi-dimensional array. As the array is being created, I want to know how deep in the array I am. 1 2 3 4 --------------------- Root A A2 A3 A4 ...

Python: Error --> setting an array element with a sequence

The data-element is a float-number and no sequence (I think). But I get the error "setting an array element with a sequence". folder = r"C:\Dokumente und Einstellungen\ssc" contents=os.listdir(folder) ar = zeros((81,81,256),int) filenumber = 0 for d in contents: if str(".bin") in d: filename = os.path.join("C:\\Dokumente u...

Turning off multidimensional arrays via POST in PHP

Is there a way to turn off the PHP functionality for Submitting a multidimensional array via POST with php? So that submission of <input type="text" name="variable[0][1]" value="..." /> produces a $_POST like so... array ( ["variable[0][1]"] => "...", ) NOT like so: array ( ["variable"] => array( [0...

sort an array base on key

i have an array like this: Array ( [0] => Array ( [title] => some title [time] => 1279231500 ) [1] => Array ( [title] => some title 2 [time] => 1279231440 ) [2] => Array ( [title] => some title 3 [time] => 127922...

How to store MySql values as Multidimensional Array using PHP

Hi, I have a database table as follows. <table border='1'><th>Id</th><th>FirstName</th><th>last Name</th><tr><td>1</td><td>Tom</td><td>T</td></tr><tr><td>2</td><td>Jerry</td><td>J</td></tr></table> I would like to store all values as a multi dimensional array using php(using a while loop to retrieve fields).That is, I would like the d...

PHP remove duplicate values from multidimensional array

We can use array_unique() for remove duplicate entry from a single multidimensional array in php.Is it possible to use with multidimensional array? It is not working for me! Here's what the array looks like Array ( [0] => Array ( [0] => 1001 [1] => john [2] => example ) [1] => Array ( [0] => 1002 [1] => test [2] => dreamz ) ...

Add rows to table even if not in array

Not sure how to title this, so I apologize if it's misleading or not understandable. What I have is an array, that array will have 1-4 arrays within it. I need a HTML table to output 4 columns, so even if the array only has one array in it, it still needs to output for columns. The issue I am hitting is that the columns need to match up....

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'), array('lname'=>'C', 'fname'=>'R','membkey'=>700,'head'=>'n'), array('lname'=>'D', 'fname'=>'S','membkey'=>540,'head'=>'y'), array('lname'=>'E', 'fname'=>'T','mem...

php array conversion help needed

Hi, $cnt[0]=>Array( [0] => 0 [1] => 0 [2] => 0 ), $cnt[1] => Array ( [0] => 1 [1] => 0 [2] => 0 ) i want convert this array to below result, $cnt[0]=(0,0); $cnt[1]=(0,0); $cnt[2]=(0,1); any php function there to convert like this format, Thanks, Nithish. ...

Global multidimensional array not being written to [vs c++]

I have a global multidimensional array, g_iAllData[MAX_LEN][MAX_WIDTH] being used in a Form. When I write to it in a function: g_iAllData[iRow][iColumn]= iByte_Count; I can see in a Watch Window that it's contents are not being changed. If I put the array in the function, it works fine. Is there something I'm missing? I am declaring ...

Algorithm to convert a multi-dimensional array to a one-dimensional array

It's easy enough to convert a 2-dimensional array to a single-dimensional array but how can I convert a multi-dimensional array of more than 2 dimensions to a one-dimensional array? For example, let's assume I have int [5][5][5] x and int [125] y and I want to place the value at x[3][4][2] in its right place in y? Hope that makes sens...