arrays

Php Arrays / Sort by Date

How would you go about implementing an array design and function to achieve the following table in php. The data would be drawn from a mysql database but i would like to limit the number of mysql queries required and therefore use a formatted array of some sort. ----------------------------------------- | | 2009 | 2008 | 2007 ...

pointer to array

I'm wondering, can you make a pointer to a group of variables in an array? like this array[20]{'a','b','c',...} pointer = array[6 through 10]; so then you could say... *pointer[0] == array[6]; and *pointer[5] == array[10]; and the length of *pointer 5 == sizeof(*pointer) \ sizeof(type); OK Let me explain what I'm trying to ...

temp. removing spaces form array objects

I have an array full of place names. One for eg is "Tower Of London" i want to put it on the end of http://en.wikipedia.org/wiki/ and open it. how do i change the spaces to underscores.. eg 'Tower of London' to 'Tower_of_London'? any ideas appreciated as always :) Cheers ...

Mixing two arrays

I am sure this is really easy, but I can't find the right function. I have two arrays, one for x values, one for y and now I want to combine them xyxyxy. for example: $x = array( 0=>10, 1=>20, 2=>30 ); $y = array( 0=>15, 1=>25, 2=>35 ); Mixed would leave: $xy = array( 0=>10, 1=>15, 2=>20, 3=>25, 4=>30, 5=>35 ); ...

how to compare two arrays of objects

i have an object called Person. It has properties First, Last, Age, etc . . . I have two arrays of Person objects. I want to have some function to take two arrays Person[] firstlist = . . Person[] secondList = . . and have it spit out two new arrays Person[] peopleinFirstListandNotSecond Person[] peopleinSecondListandNotFirst ...

Why array values in java is stored in heap?

Programing languages like C,C++ will not store array values in Heap rather it keeps the value in STACK. But in Java why there is a necessity to keep array values in heap? ...

Floating point exception on a int Array - C

int check_row; for (n=0; n<9; n++) { used_numbers[n] = n+1; } for (row=0; row<3; row++) { for (check_row=0; check_row<3; check_row++) { used_numbers[(sudoku[row][check_row]-1)] = 0; } ... int sudoku[9][9] declared as global variable and used_numbers[9] as int. In sudoku matrix for row from 0 to 2 and col from 0 to ...

c++ typecast array

How can one typecast an array of int to an array of float? Thanks. ...

Accessing Javascript Array without using [] Brackets

I'm trying to write some javascript in an environment where square brackets are used for macro replacement, so they can't be used as normal in the script. If I create an array as an object with new Array() I can use push() and pop() to access the elements, but for native arrays I can't figure out a way to get to the elements without usi...

How-to implement a custom debugger visualiser in VS2008 on an array using a WeakReference?

I would like to implement a custom debugger visualiser in vs2008 for a typical array as the standard one does not display the data as I would like it. However Visual Studio prevents doing this for arrays for security reasons. I seem to remember though reading about using a WeakReference as a wrapper object to get around this limitation....

Multidimensional Associative Arrays in VB.NET?

Hi, is there in VB.NET something like this in php?: $var["a1"]['name']="Mike"; $var["a1"]['nick']="MMM"; I tried hashtables, dictionary, lists and arrays in .net, all I could get is a simple key=>value array Is there a simple solution if not, is there a class or something for this? Thanks. ...

Quickly Determining the Position of Data in an Array

I have a data structure as the image below illustrates. I need to quickly figure out the index of the cells to the right or left of the highlighted cell group. You can see in the code below I am naively looping through ALL cells at every index to determine if there is a cell at the requested index. This works great when I have a few (...

c reading a text file into array line by line and print them

hi, i have the following c# code snippet string[] lines = File.ReadAllLines(@"C:\test.txt"); for(int i=0; i<lines.Length; i++) Console.WriteLine(lines[i]); Can you help me to convert it to C. Thanks! ...

In PHP: How can I filter a subset of one array into another?

foreach ($myarray as $value) { if (strpos($value,'mysearchstring')) //add this $value to new array here } Also where would the second array need to be declared and how? ...

Group select boxes into array for post?

I know how to send data via a multi-select form object and group the data into an array: <select name="my_data[]" multiple="multiple"/> Is it possible to have multiple different select boxes with "single" values and push them all into an array? i.e. <select id="select-1" name="my_data[]"/> <select id="select-2" name="my_data[]"/> r...

question on struct with char array

Below is my code snippet struct encode { char code[MAX]; }a[10]; int main() { char x[]={'3','0','2','5','9','3','1'}; for(i=0;i<1;i++) { printf("%c",x[i]); //This will printout like 3025931 now I want this to be stored in structure. } strcpy(a[0].code,x); // or a[0].code=x;//neither works display(); }...

filter an array in C#

i have an array of objects (Car[] for example) and there is an IsAvailable Property on the object i want to use the full array (where IsAvailable is true for some items and false for some others) as the input and return a new array which includes only the items that have IsAvailable = true. ...

I have same struct question for int array..

paxdiablo gave the previous answer for it working with char array.. can I know how to work with int array for the same below code? LIke: struct encode { int code[MAX]; //instead char code[MAX] } a[10]; int main() { int i, j; int x[] = {3,0,2,5,9,3,1}; //instead char x[] = {'3','0','2','5','9','3','1','\0'}; for(i ...

how to split a string into an array but only split on the first instance of a character (space in this case)

i have a string "ABC DEF EFG" and i want to get an array: array[0] = "ABC" array[1] = "DEF EFG" ...

Why [] is used in delete ( delete [] ) to free dynamically allocated array ?

I know that when delete [] will cause destruction for all array elements and then releases the memory. I initially thought that compiler wants it just to call destructor for all elements in the array ,but i have also a counter - argument for that which is: Heap memory allocator must know the size of bytes allocated and using sizeof(Ty...