multidimensional-array

PHP: Need to merge/sort a multidimensional array based on one key in the dimension

I hope I will be able to explain what I'm trying to do - and really hope someone will be able to help! Here is the array I am working with ( [0] => Array ( [city] => Middletown [state] => OH [freq] => 146.610 [pl] => 77.0 [call] => W8BLV [distance] => ...

C++ - Memory issues with two dimensional array

Hi guys, Following this nice example I found, I was trying to create a function that dynamically generates a 2D grid (two dimensional array) of int values in C++. It works fairly well the first couple of times you change the values but if crashes after that. I guess the part where memory is freed doesn't work as it should. Any ideas w...

sorting part of a multidimensional array

I have an multi dimensional array: $array[0] = array ( name => "Bob", position => "Chair", email => "[email protected]" ); $array[1] = array ( name => "Al", position => "", email => "[email protected]" ); //etc.. I want to sort it so that those whose position != "" are first, then the rest alphabetically by name... I'm not very fam...

PHP: Get key from array?

Hi everybody, I am sure that this is super easy and built-in function in PHP, but I have yet not seen it. Here's what I am doing for the moment: forEach($array as $key => $value) { echo $key; // Would output "subkey" in the example array print_r($value); } Could I do something like the following instead and thereby save myse...

How to convert an int[,] to byte[] in C#

List item How to convert an int[,] to byte[] in C#? Some code will be appreciated EDIT: I need a function to perform the following: byte[] FuncName (int[,] Input) ...

Trying to convert an int[] into int[,] using C#

Hi, I would like a function to convert a single dimension array int[480000] into a 2d array of size int[800,600]. Can you please help me how this can be done? ...

Converting a multi-dimensional array (javascript) to JSON (or similar) for transport.

I'm generating a multi-dimensional array in javascript that looks like this (this is the JSON representation of the javascript array, it's not in JSON format): "100": { "40": { "subtotal": "24.99", "turn-around": { "0": "2-4 Business Days", "1": "Next Business Day (Add $15.00)" }, "shipping": { "...

How to print an a 4x4 array in clockwise direction using C#

int numbs[4][4] = 1, 2, 3, 4 5, 6, 7, 8 9, 10, 11, 12 13, 14, 15, 16; When i print it, it should print like this. 1 2 3 4, 8, 12,16, 15, 14, 13, 9, 5, 6, 7, 11, 10, (ie clockwise direction spiral): ---\ //first right, then down, left, up and repeat /-\| |-/| \--/ ...

PHP Return Section of a Multidimentional Array

I have an array with a series of event IDs organized like this: $event['year']['month']['day'] = $event_id (full structure below). Basically, I want to output the next 5 events (or so) from a given date (such as today). I've gone through the PHP manual, but haven't found a suitable solution. I suppose I could just iterate through each ...

Conflicting types in a 2D array (C)

Hello, I am making my first C program, and it utilizes a 2D array, and the code seems weird to me. First, why do I have to store "White" in [1][6]? I tried [0][6], but the compiler complains and won't run but when I call it in printf, it's [0][6]. Also, when trying to store "Bl" in codes [2][6], it says conflicting type for codes. An...

Ruby - problems with user input to integer array

I am trying to accept input of two integers, separated by a space: 3 5 and save that into an integer array. I do this 3 times, but I am having trouble converting this from string to integers. Here is my loop: for i in 1..3 puts "What is point " + i.to_s + " ?" # asks for input s.push gets.split(" ") end Then, I want to have...

Arithmetic operation so that 0, 1, & 2 return 0 | 3, 4, & 5 return 1, etc.

Hello SO community! I'm trying to take 9x9, 12x12, 15x15, etc. arrays and have the program interpret them as multiple 3x3 squares. For example: 0 0 1 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 6 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 0 0 0 0 8 0 0 0 9 Will be understood as: 0 0 ...

Create another dimension to an array housing urls with base url.

Currently I have an array that lists email addresses as the key and urls as the values, I want to use parse_url (unless something better is suggested) and create another dimension to the array with the base url. This is what I currently have: array ( '[email protected]' => array ( 0 => 'http://www.google.co.uk/foo/bar', 1 => '...

Multi-dimensional array and pointers in C++?

int *x = new int[5](); With the above mentality, how should the code be written for a 2-dimensional array - int[][]? int **x = new int[5][5] () //cannot convert from 'int (*)[5]' to 'int **' In the first statement I can use: x[0]= 1; But the second is more complex and I could not figure it out. Should I use something like: x[0]...

How do I populate a "ragged" array with values of a text file being read?

Hello, I'm new to Stack Overflow, and this is my first question/post! I'm working on a project for school using Java. The first part I'm having trouble with inolves: Read each line in a file (listed at the end of my post) one time Create a "ragged" array of integers, 4 by X, where my 4 rows will be the "region number" (the number found...

C++ - Vector-based Two dimensional array of objects

As suggested here I fixed my 2D array of numbers to make it work with Vector class. Header file: #include <vector> typedef std::vector<int> Array; typedef std::vector<Array> TwoDArray; And here is how it's used: TwoDArray Arr2D; // Add rows for (int i = 0; i < numRows; ++i) { Arr2D.push_back(Array()); } // Fill in test data ...

help sorting this array.

So I am looking to sort the multi dimensional array below by "fk_page_id" ascending. Does anyone have any pointers. I think usort() is where I have to look but it seems like I cant find anyone with my specific array structure. Array ( [0] => Array ( [title] => subpage of subpage! [id] => 5 ...

Runtime allocation of multidimensional array

So far I thought that the following syntax was invalid, int B[ydim][xdim]; But today I tried and it worked! I ran it many times to make sure it did not work by chance, even valgrind didn't report any segfault or memory leak!! I am very surprised. Is it a new feature introduced in g++? I always have used 1D arrays to store matrices by ...

initializer-string for array of array of chars is too long

I am making a patcher for a game but I get the error "initializer-string for array of array of chars is too long" from Mingw. I am trying to make a multidimensional array of chars to contain what functions to patch. I have checked for other questions about this and found one where the asker forgot to add commas to the end of every string...

how to get value inside an array without knowing the key of that multidiensional array

i have below array structure $movieCast=Array ( [1280741692] => Array ( [moviename] => twlight [movie_cast] => Array ( [0] => 0000000083 [1] => 0000000084 ) [userid] => 62 [country_id] => 00...