arrays

Sort PHP array?

I have the following? $array1 = array(); $array2 = array($Id, $Name, $Count); array_push($array1, $array2); I want to sort array1 on the $count? sort() and ksort() don't do what i require? Any ideas? Thanks Edit: I am inputing an Id number, name text and number of times the name occurs, so I want to to have the name with the hi...

How to fill-up cells within a Excel worksheet from a VBA function?

Hello, I simply want to fill-up cells in my spreadsheet from a VBA function. By example, I would like to type =FillHere() in a cell, and in result I will have a few cells filled-up with some data. I tried with such a function: Function FillHere() Dim rngCaller As Range Set rngCaller = Application.Caller rngCaller.Cells(1, 1) = "...

Return PHP array name

Array ( [kanye] => Array ( [0] => Kanya [1] => Janaye [2] => Kayne [3] => Kane [4] => Kaye ) [wst] => Array ( [0] => ST [1] => St [2] => st [3] => EST [4] => West ) ) Array ( [0] => Kanya [1] => Janaye [2] => Kayne [3] => Kane [4] => Kaye ) Array ( [0] => ST [1] => St [2] => st [3] => EST [4] => W...

Selectively flattening a PHP array according to parent keys

I need to selectively flatten an array in PHP, but do it selectively. If a key matches a pattern then all sub elements below that key should be included in the 'flat' output. SO If I had a catalogue of music: => array of albums => each of which is an array of song titles Then I could search for a string, and would get a flat array in...

Reading and writing to a buffer

Hi, I have 2 classes, one that writes multiple 96bit objects to a buffer (32bits at a time - 3x int32), and one that i want to read from the same buffer. The first class (Writer) reserves and area of memory and creates a pointer to the first 32bit area. 1) How do I write to the buffer safely (ignoring buffer overflow for now)... I nee...

Why is 2[myArray] valid C syntax?

Duplicate In C arrays why is this true? a[5] == 5[a] Given an array myArray[5] = { 0, 1, 2, 3, 4 }; an element can be accessed as 2[myArray] Why? When I see this expression I'm imagining C trying to access the pointer "2" and failing to add "myArray" pointer increments to dereference that address. What am I missing? ...

merge two arrays based on array1

Hi, I'm trying to merge two arrays for the values of array1 that are set Array1 ( [0] => false [1] => 200 ) Array2 ( [0] => true [1] => 80 [2] => 60 [3] => 75 [4] => 50 [5] => 0 [6] => 0 [7] => 30 [8] => 40 ) for instance result array: Array3 ( [0] => false [1] => 200 [2] => 60 [3] => 75 [4] => 50 [5] => 0 [6] => 0 [7] => 30 [8] => 4...

How to sort a part of an array with int64 indicies in C#?

The .Net framework has an Array.Sort overload that allows one to specify the starting and ending indicies for the sort to act upon. However these parameters are only 32 bit. So I don't see a way to sort a part of a large array when the indicies that describe the sort range can only be specified using a 64-bit number. I suppose I could...

Passing arrays as parameters in VB6

The following code kills VB6 (sp6) with an 'unhandled exception fault in VB.exe' on two machines in the office on the line marked. ''# Form1.frm Option Explicit Private ArrayHolder As Class2 Private Sub Command1_Click() Set ArrayHolder = New Class2 Dim arr(3) As Long arr(0) = 1 arr(1) = 2 arr(2) = 3 ArrayHolde...

How do I find the elements of an array in C++ which sum to a value greater than or equal to a specific number?

I've written a loop in C++ to give me 6 random numbers and store them in an array. What I would like to do is to sum the elements of the array until I get a value larger than a number, "x", but I would like to do this without necessarily adding all the elements. The objective is to find the first elements which sum to the value of x. ...

How to pass an array in by reference to a function in Objective C

Greetings everyone! I have a function that has an array pointer passed it to modify stuff in an array: (void) arrayFunction:(Byte[])targetarray { // do stuff to targetarray } It's an array of type Byte, but I don't think that I've put the right thing in the round brackets. What should it be instead of (Byte[])? There may be several...

Ways in .NET to get an array of int from 0 to n

I'm searching the way(s) to fill an array with numbers from 0 to a random. For example, from 0 to 12 or 1999, etc. Of course, there is a for-loop: var arr = int[n]; for(int i = 0; i < n; i++) { arr[i] = i; } And I can make this method been an extension for Array class. But is there some more interesting ways? ...

How Big can a Python Array Get?

In Python, how big can an array/list get? I need an array about 12000 elements large... is that okay? - will I still be able to run array/list methods such as sorting, etc? Thanks so much, Ed ...

Is there a better way to find the location of a minimum element in an Array?

Right now I have def min(array,starting,ending) minimum = starting for i in starting+1 ..ending if array[i]<array[minimum] minimum = i end end return minimum end Is there a better "implementation" in Ruby? This one still looks c-ish. Thanks. ...

Which Algorithm Does Ruby's Sort method use?

When I sort an Array using the native sort method, which algorithm does RUBY decide to use? Is it data-dependant (i.e If the data is small it uses X algorithm else uses Y algorithm)? Is it a stable sort? What is the average time complexity? ...

Best way to Find which cell of string array contins text

I have a block of text that im taking from a Gedcom (Here and Here) File The text is flat and basically broken into "nodes" I am splitting each node on the \r char and thus subdividing it into each of its parts( amount of "lines" can vary) I know the 0 address will always be the ID but after that everything can be anywhere so i want ...

arrays in python

Hi I just started work on my first python script What's the best way to create 2 D arrays in python ? What I want is want is to store values like this : X , Y , Z so that I access date like X[2],Y[2],Z[2] or X[n]Y[n],Z[n] where n is varialble I don't know in the beginning how big n would be so I would to append values at the end ...

I need to push into an array values based on a specific condition, what is the correct way to do this?

I have a forcycle that contains a condition (and an incremental value i): if(condition)){$arr[$i] = array("value" => $node->nodeValue));} else{$arr[$i] = array("string" => $node->nodeValue);} In the end I need to have an array like this: Array ( [1] => Array ( [string] => abc [value] => 0,999 ) [2] => Array ( [string...

Is there some kind of unseen Array termination in Ruby?

I am writing an method that takes variable lengths of arrays and compresses and converts them to matching array lengths. The method accepts an array length of anywhere from 50 to 126 . .. and converts them down based on parameters when called. This means is I am dynamically accessing ranges that are specified at method call. This also ...

Problem with array values...

I am having a problem where a routine (that I cannot modify) is returning me either a 3 nested array -or- a 2 nested array. The key values are never the same, however, I'd like to normalize the nesting so that I can make the 2 nested array 3 levels deep every time to avoid "Notice: Undefined index:" errors. Or if possible, have a routi...