arrays

Finding the position of an element in a simple array

Hello, Let's say we have this array: Array ( [0] => 10 [1] => 45 [2] => 23 ) How can I determine the position of element '45' in this array? I'm using PHP. Thank you. ...

How can I remove a single array member using array_splice in php?

I think I may not understand correctly how array_splice is supposed to work. My understanding is that the first param is your initial array, the second param is the element to start at, and the third param is the length, or number of elements to remove/replace. So, I have this array (print_r output): Array ( [0] => Array ( [TypeFlag] ...

Sorting Mulitdemensional Array PHP

I have the following array, it is currently created sorted by entity_count (outputted by a query done in cakephp - I only wanted the top few entities), I want to now sort the array for the Entity->title. I tried doing this with array_multisort but failed. Is this possible? Array ( [0] => Array ( [Entity] => Arra...

PHP Strange NULL variable situation

Hi Everyone, I'm having a tough time with this one, I have a class which populates an array. Sometimes the array will not be populated and I want make an edge-case for when this happens however I can't seem to tell when its null! Here's the code: $results_dev = $class->get_data_nologin("4a9d-4f41-9566-7705",$key,"Sensors"); echo ...

Bit Array in C++

When working with Project Euler problems I often need large (> 10**7) bit array's. My normal approach is one of: bool* sieve = new bool[N]; bool sieve[N]; When N = 1,000,000 my program uses 1 MegaByte (8 * 1,000,000 bits). Is there a more efficient way to use store bit arrays than bool in c++? ...

How do I add multiple components to a PickerView?

Hi, It may be a simple question but how do I add multiple components to a UIPickerView? I use NSMutableArray to populate one component but I dont know how to populate the others. I also need to change the value of a label when a row is selected. Thanks in advance Kieran ...

Subsetting data in python

Hi, I want to use the equivalent of the subset command in R for some python code I am writing. Here is my data: col1 col2 col3 col4 col5 100002 2006 1.1 0.01 6352 100002 2006 1.2 0.84 304518 100002 2006 2 1.52 148219 100002 2007 1.1 0.01 6292 10002 2006 1.1 0.01 5968 10002 2006 1....

Replace string within a array

NSArray *ArtistNames = [RawData componentsMatchedByRegex:regEx1]; NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@"'"]; ArtistNames = [[ArtistNames componentsSeparatedByCharactersInSet: doNotWant] componentsJoinedByString: @"'"]; Thats my code at the moment basically i cannot use it as A...

C++ converting an int to an array of chars?

Possible Duplicate: C++ convert int and string to char* Hello, i am making a game and I have a score board in it. The score is stored in an int variable but the library im using for the game needs an array of chars for its text outputting for my scoreboard. So how do i turn an int into an array of chars? int score = 1234; ...

Odd one: @myRecordArray[0] returns invalid pointer if array size is bigger than 4136

hello stack, this is really strange, i have an array in delphi and fill it with directX matrices. then i get the pointer to the first element and pass it via com to c# managed code: function TMPlugTransformInPin.GetMatrixPointer(out SliceCount: Integer; out ValueP: Int64): HResult; var matrices: array of TD3DMatrix; i: Integer;...

Recursively replace keys in an array

Hi, I can't quite work this out... I was hoping that there would be a default PHP function to do this, but it seems there isn't. The code I've found online seems to not really work for my situation, since often people have only need to the modify array values and not their keys. I basically need a recursive function that replaces every...

Javascript Arrays - Alternative to arr[arr.indexOf()]?

var arr = [foo,bar,xyz]; arr[arr.indexOf('bar')] = true; Is there an easier way to do this in JS? ...

What is the difference between sizeof(int) and sizeof(int*)? Also Is this statement int* numbers[] = {....} correct?

Suppose, int numbers [20]; int * p; I think this is statement is valid p = numbers; But this is not numbers = p; Because numbers is an array, operates as a constant pointer, and we cannot assign values to constants. So if we go by this then we cannot use *numbers while initializing the array? ...

How to persist/store values at runtime.

I have a scenario which is as follows:- A form containing 2 grids. The grid on the left contains a list of groups. When a group is selected the grid on the right populates with another list with check boxes. I would like to be able to select group A and select some random check boxes and then switch to group B and select some other che...

void* or char* for generic buffer representation ?

Hi, I'm designing a Buffer class whose purpose is to represent a chunk of memory. My underlying buffer is a char* (well, a boost::shared_array<char> actually, but it doesn't really matter). I'm stuck at deciding what prototype to choose for my constructor: Should I go with: Buffer(const void* buf, size_t buflen); Or with: Buffer(...

Push multidimensional arrays into array?

I have a arrays like this. $pahrmacyid=array( "Identification"=>array( "ID"=>array( "IDValue"=>$_GET['pharmacyid'], "IDQualifier"=>"D3" ) ) ); $storename=array( "StoreName"=>$_GET['storename'] ); $pharmacyaddress=array( "Address"=>array( "AddressLine1"=>$_GET['paddress'], "City"=>$_G...

PHP array to multidimensional array

I have an array in php with Objects containing an id and a parent_id. All Objects without a parent_id should be the root Objects in a new array. All Objects that do have a parent_id should be pushed in the correct Object's children array: So this is my original array: array 0 => object(Node)[528] protected 'id' => int 1 ...

How can I declare a two dimensional string array in C#?

string[][] Tablero = new string[3][3]; I need to have a 3x3 array arrangement to save information to. How do I declare this in C#? ...

Accessing an array within a hash - Ruby

Hello, I'm writing an application that pulls values out of an excel spreadsheet and then stores those values in a hash using the version number as a key. Everything seems to be working correctly until I try and retrieve the information from the hash. Here is the code that builds the hash. @version_numbers.each do |version| user_var...

Declaring an array with a non-constant size variable

Hi I'm studying for my test in C and I'm reading in a C summary I downloaded from some site. It is written that it is not allowed to write arr[i] where i is a variable. The only way to do it is with malloc. However, I wrote the following code and it compiles without warnings and without error on valgrind: int index = 5; int a4[...