arrays

How do I invert a multidimensional array in PHP

Whats the easiest way to invert a multidimensional array. By invert I mean similar to array_flip. e.g [0][5][var_name] = data [0][3][var_name2] = data2 [1][var_name3] = data3 [0][1][4][var_name4] = data4 inverted would be: [var_name][0][5] = data [var_name2][0][3] = data2 [var_name3][1] = data3 [var_name4][0][1][4] = data4 Any ide...

how to access array[3..last] (ruby)

how can I access all array elements from x to the last one? my_array= [1,2,3,4,5,6] puts my_array[3..last] ...

python script for robust multi-array average on microarray data

I have tried google with no luck. I have seen some weak references to robust multi-array averaging done with python but no code. I am not so interested in reinventing the wheel. Any suggestions on a python module, script .... If I could find a nice explanation or example of the algorithm I would write a python implementation to share. ...

arrays VB.NET vs c

just a sanity check please: in VB.NET: dim myarray(5) as integer gives six elements 0 to 5 but in c? int myarray[5]; gives five elements 0 to 4 ? is this correct? ...

Accessing array from multiple threads

Let's say I have two arrays: int[] array1 = new int[2000000]; int[] array2 = new int[2000000]; I stick some values into the arrays and then want to add the contents of array2 to array1 like so: for(int i = 0; i < 2000000; ++i) array1[i] += array2[i]; Now, let's say I want to make processing faster on a multi-processor machine, so i...

How do I declare the size of a string array if it's a member function.

I have a problem with setting the size of my array. In my code I have: class Test { public: ....//Functions private: string name[]; }; Test() { //heres where i want to declare the size of the array } Is this possible? ...

C++ 2D Dynamic Array

Hi, I am trying to dynamically assign a 2d array to a pointer in a constructor initialize. FooBar::FooBar() : _array( new int[10][10] ) { } int **_array; However this does not work. I understand that multidimensional arrays are allocated a bit differently. Is anyone able to elaborate on this with an explanation? Thanks in advan...

Dynamically allocating an array of size 0

Possible Duplicate: C++ new int[0] will it allocate memory? What is supposed to happen when i do this: int * MakeArray( std::size_t Size ) { return new int[ Size ]; } MakeArray( 0 ); We had this is out code (using VC++ 2005), and the debug-heap complained about a memory-block of size 0 that was not deallocated. Is it ...

Convert Javascript Array to JSON

Hay I have an Array (var cars = []) which hold a few integers. I've added a few values to the array, but i now need to send this array to a page via jQuery's .get method. But i want to send it as a JSON object. How do i convert an array to a JSON object? ...

php & mySQL: Selecting Multiple Books and showing their info in next screen

Hi all, Let me illustrate this with an example. Consider there are 10 books (there may be more, even 100+ on a single screen). A customer can order any number of books. In the fontend, each book is represented in a row and the book details are arranged column wise. Now the 10 books (along with their details) are shown in 10 rows. BOO...

Array of classes. Stack or heap?

class temp; temp *t; void foo() { temp foo2; t[1] = foo2; } int main() { t = new temp[100]; foo(); //t[1] is still in memory? } If i want an array of classes like this, am i going to have to use pointer to pointer? (and use 'new' on each element in the array) E.G: temp **t; if i want to make an array of 100 ptr to ptr...

Acessing a QC Structure from a Cocoa Application

Hi there, is there a way of acessing a structure from a Cocoa app? I am able to set integers and Strings using the QCView setvalue:forkey method but when i try to access a structure i run into errors. Basicly what i want to do is to pass a byte array into a Quartz composition. greetings matthias ...

How to propagate a current menu item flag upwards in a multidimensional array?

I have a menu being built via a multi-dimensional array. A current item is set by matching its url attribute with the current request. I want this value to bubble up to its parents, but I can't for the life of me get it working - I'm sure I've been close, but it's proving a bit tricky. Here's the array: Array ( [children] => Array ...

PHP - write to first element of an array

How to write to the first element of an array? I know reset can return the first element... but you can not use it to write to it. ...

Ruby URL regex matcher

Hey, I have some content with a list of URLs contained in it. I am trying to grab all the URLs out and put them in an array. I have this code content = "Here is the list of URLs: http://www.google.com http://www.google.com/index.html" urls = content.scan(/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*...

in PHP, how do I create an array of all strings between two strings?

I have a chunk of text like: <b>First content</b> followed by <b>second content</b> OR "First content" and then "second content" And I want to create an array that looks: [1] => "First content" [2] => "second content" From either example, where I get the content between two tags. I've figured out how to get the first instances, bu...

PL/SQL Array to CLOB

Hi, i m using Oracle 9i. I m fetching data from a cursor into an array : FETCH contract_cur BULK COLLECT INTO l_contract ; But now i want to "convert" this *l_contract* into a CLOB variable *l_clob* Is there an easy way to do that? Or otherwise, how do i convertthe rows from a SELECT statement into one single CLOB Variab...

PHP - Getting position within a loop

Hi, I have a function which is called within a foreach loop and takes in two parameters, an integer, representing the number of times the loop has run and an array (of no fixed size). I would like to return the value of the array key that is equal to the counter. For example, if the array has four elements: A, B, C and D and the counte...

Javascript: Convert textarea into an array

How would you go about breaking up a textarea value into an array, based on the end of line separation? Use of jQuery is cool by me... ...

Javascript: Put array into a text field

How would you go about putting an array into a textarea, each value on its own line? I thought about converting the array to a string, and the commas into new lines, but what if the value of an array item has a comma? ...