multidimensional-array

Why is this multi-dimensional array acting funny in C#?

Ok, first of all, I originally programmed this csv parser in PHP. It is for a specialized kind of CSV file that we use internally. Anyway, I wanted to move it to C# to get some experience with the language. The only thing I can see that is different between the two (scripts?) is that I changed sqlarray from a 3-dimensional jagged arra...

Best solution for "Array chaining"

For my project I wrote a small config class that loads its data from a .ini file. It overwrites the magic __get() method in order to provide simplified access to the (read only) config values. Example config.ini.php: ;<?php exit; ?> [General] auth = 1 user = "halfdan" [Database] host = "127.0.0.1" My config class (singleton pattern...

Store a large PHP array, plain php, or gzipped serialized data?

I have a static large array-of-arrays, witch represents tree structure with about ~100k nodes, this array is only read-only reference for value lockups. Now, witch of this methods will perform better? First, simply array definition in pure PHP file, for including in requests Second, serialize this array, gzip serialized output, and lo...

Returning a reference array from a const member function

How do I return an array reference from a const member function? class State{ Chips (&arr() const)[6][7] { return arr_; } Chips val() const { return val_; } } Invalid initialization of reference of type 'Chips (&)[6][7]' from expression of type 'const Chips [6][7]' Thank you. ...

unsetting an array within an array

In the screenshot, you can see i have an array of arrays. I need to find an array that contains say, 'Russia', and unset it completely. That is, for Russia, remove the element [303]. I've played around with array search but I'm sure theres a funkier way of doing this. Chris. ...

Arrays of strings in C

I need to hold an array of C strings. Now I know C strings are just an array of chars so essentially what I want is a 2d array of chars. The strings I'm trying to store will also never exceed 6 characters. My plan is to initialize a char array with 50 "string slots" and then if I hit 50 strings reallocate the array's memory to double it'...

How to combine multiple arrays with identical keys into a single array ?

hi to all. I am new to php. I need some help. I had a array as Array ( [_] => Array ( [0] => [1] => ) [123_] => Array ( [0] => 123 [1] => ) [1234_] => Array ( [0] => 1234 [1] => ) ) Array ( [_] => Array ( [0] => [1] => ) [12345_] => Array ( [0] => 12345 [1] => ) [1234_] => Array ( [0] => 1234 [1]...

Double array through pointers in C

I want to scan a 2D array with the help of pointers and have written this code, could you tell me why the compiler gives errors? #include<stdio.h> #include<stdlib.h> int main(void) { int i,j,n,a,b; int (*(*p)[])[]; printf("\n\tEnter the size of the matrix in the form aXb\t\n"); scanf("%dX%d",&a,&b); p=(int (*(*p)[b])...

2D array through pointers.

I want to scan a 2D array with the help of pointers and have written this code, could you tell me why the compiler gives errors? I know how to use double pointers to do the same, i was experimenting with this one. #include<stdio.h> #include<stdlib.h> int main(void) { int i,j,n,a,b; int (*(*p)[])[]; printf("\n\tEnter the size...

PHP: Accessing array variables

Can someone help me access this array please I'm having trouble with indexes. array(10) { [0]=>array(2) { ["t"]=>array(1) { ["tag"]=>string(3) "php" } [0]=>array(1) { ["NumOccurrances"]=>string(1) "2" } } [1]=>array(2) { ["t"]=>array(1) { ["tag"]=>st...

Initializing 2 dimensional array of structs in C++

Hi, I am trying to initialize a 2D array of structs in C++, but am getting an error. Can someone please tell me what am I doing wrong? I have rechecked the braces and they seem to be fine. My code: struct CornerRotationInfo { bool does_breed; int breed_slope; bool self_inversion; int self_slope; inline CornerRotationInfo(b...

Using func_get_args to edit an array

I wish to use a function with an arbitrary number of arguments to edit an array. The code I have so far is: function setProperty() { $numargs = func_num_args(); $arglist = func_get_args(); $toedit = array(); for ($i = 0; $i < $numargs-1; $i++) { $toedit[] = $arglist[$i]; } $array[] = $arglist[$numargs-1]; } The ...

Efficient conversion of an array into a two-dimensional one using LINQ

I want to do the below in a performant way in C#, preferably using LINQ. Array[Length] to Array[Length/Row][Row] where Row and Length are variables. ...

Initializing multidimensional NSArray for iPhone devel

Hello, i'm starting in iPhone devel and i need to use a multidimensional array. I init it using: NSArray *multi=[NSArray arrayWithObjects:[NSMutableArray arrayWithCapacity:13], [NSMutableArray array],nil]; when i try to assign values to n-th cell like: [[multi objectAtIndex:4] addObject:@"val"]; App hangs because of index 4 b...

C Programming weird struct setup

I am trying to build this project and for some reason the program hangs when I run it. It works fine if i comment out the data cache lines. but it cannot make a call to makeCache for two different caches i dont know why any C experts know. Im new to c. /* * main.c * * Created on: Sep 16, 2010 * Author: TJ */ #include <std...

What is the most efficient way to store and parse data in AS3?

What way of reading and storing data is fastest for AS3. For debugging right now it is just reading the raw XML, but I suspect it would be faster if I made them into nested arrays. Would parsing the XML into nested arrays to be read later be the most efficient method?, or is there a better way to read lots of data? ...

C++: how to access a multidimensional array with pointers?

Given: (In C++) int main () { int* ptr; int ary [10][2]; ptr = ary; return 0; } How would I access ary[0][1] with ptr? ...

How do I find max values in a multidimensional array?

I Have an array which looks like this: Array ( [0] => Array ( [0] => Array ( [product] => 2003 [date] => 2010-09-15 13:27:35 [status] => 3 ) [1] => Array ( [product] => 2004...

How to overwrite pointer assoziation in php? Or how to operate on arrays with n dimensions?

Hi, I have a nasty little problem with the pointer opperator in php (&). I want to loop through a while loop, which writes data in an array. Each time it is supposed to write into the next dimension of the array (1st in $array, then in $array[0], then in array[0][0], etc). I wanted to do this by linking to $array with a pointer, then ch...

PHP Array Combination Best Method

given the following arrays in php, how can i best merge them together $masterkeys = array('Key1','Key2'); $settings_foo = array( array('ID'=>'Key1', 'Foo_Setting'=>'SomeValue')); $settings_bar = array( array('ID'=>'Key1', 'Bar_Setting'=>'SomeOtherValue')); in the end I need $masterkeys to be the comb...