arrays

php associative arrays, regex, array

I currently have the following code : $content = " $content = " <name>Manufacturer</name><value>John Deere</value><name>Year</name><value>2001</value><name>Location</name><value>NSW</value><name>Hours</name><value>6320</value>"; I need to find a method to create and array as name=>value . E.g Manufacturer => John Deere. Can anyone ...

How to split an array into a group of n elements each?

What is the best way to group an array into a list of array of n elements each in c# 4. E.g string[] testArray = { "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8" }; should be split into if we take n=3. string[] A1 = {"s1", "s2", "s3"}; string[] A2 = {"s4", "s5", "s6"}; string[] A3 = {"s7", "s8"}; May be a simple way using LINQ? ...

How can I implement a custom reorganization function that returns a nested array?

I have this data coming from a database which pulls all subcategories and relevant info: $data = array( array( 'destination_name' => 'Ohio Resort', 'destination_slug' => 'ohio', 'subcategory_name' => 'Bird Hunting', 'subcategory_slug' => 'bird-hunting', 'category_name' => 'Hunting', 'c...

How to combine an array of keys with corresponding values from another array?

I have 2 arrays Array ( [1] => Manufacturer [2] => Location [3] => Hours [4] => Model ) and Array ( [Manufacturer] => John Deere [Location] => NSW [Hours] => 6320 ) I need to combine them and associate the values from the first array( Manufacturer, Location, hours , Model) as names in the 2nd array and if a specific values f...

Passing two-dimensional array via pointer

How do I pass the m matrix to foo()? if I am not allowed to change the code or the prototype of foo()? void foo(float **pm) { int i,j; for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) printf("%f\n", pm[i][j]); } int main () { float m[4][4]; int i,j; for (i = 0; i < 4; i++) for (j = 0; j ...

What are the ramifications of passing & assigning arrays as pointers in C++?

As background, I gave an answer to this post a little while ago: http://stackoverflow.com/questions/3473438/c-return-array-in-a-function/3473448#3473448 And it unintentionally kicked off a really long comment chain about pointers vs. arrays in C++ because I tried to oversimplify and I made the statement "arrays are pointers". Though m...

php, manipulate arrays, combine array, associative

I have an array like $array = Manufacturer => BMW Miles => 10000 and I would like to use this to create a new array with a specific name/value like this : $array = st_selval_0_0 => Manufacturer st_tmdata_0_0 => BMW st_selval_0_1 => Miles st_tmdata_0_1 => 10000 As you can see the last digit mu...

Merge 2 associative arrays of different lengths where a key (datetime) matches in both arrays.

I have 2 arrays, each with a date string and a string value representing 'amount'. The first array has a row for every day between start_date and end_date, but has nothing for 'amount'. The second array has fewer rows, but has the amount. I need to merge the 2 arrays so that I end up with a row for every day, with an amount for that day,...

Literal Syntax For byte[] arrays using Hex notation..?

The compiler seems to be ok with this (single digit hex values only): byte[] rawbytes={0xa,0x2,0xf}; But not this: byte[] rawbytes={0xa,0x2,0xff}; I get a "Possible Loss of Precision found : int required : byte" error? What am I doing wrong - or are single digit hex numbers a special case ? Java 1.5.x. ...

saving an array

how is it possible to save an array in multiple locations ie. different view controllers in order to save the data in the arrays and allow it to be used afterwards by a table? edit objective c i have an ibaction with code [[NSMutableArray alloc] init]; [favoritesArray addObject: @"one"]; //and in the fav table view this code// favori...

Why are C# arrays covariant and what benefits does it bring?

Hi all, I'm having trouble understanding why arrays in C# are covariant and what benefits this covariance can bring. Consider the following trivial code example: object[] myArray = new string[1]; myArray[0] = 1; This code will compile okay, but will unceremoniously and perhaps unsurprisingly explode at runtime. If I try to attempt t...

What is the function that will truncate string in an array?

I'm still new to PHP and I couldn't find this in the manual because I'm not sure of the name of the function. I have an array with These values: $files[] = [0] => 01_Nhemamusasa.mp3 [1] => 02_Kari_Mudande.mp3 [2] => 03_Chikende.mp3 [3] => 04_Karinge_Zuva.mp3 [4] => 05_Mbirimo.mp3 [5] => 06_Muchenjedza_Mutonga.mp3 [6] => 07_Skok...

How to pass string array as BSTR* to web service proxy

In VS2005 I have generated a web reference to a web service that takes a 1-dimensional array of strings ("inputArray") as an input parameter. The proxy function generated for this web service call asks for two parameters: BSTR *inputArray int inputArray_nSizeIs What is the proper syntax for passing in inputArray as a BSTR*? Currentl...

Javascript For Loop On Array of Input fields issue with document.getElementById

Hello, I have an serverside script making an amount of text fields for me. When I want a user to fill them up, and submit data. I know how many fields there are, as the server also sends a count. I am then trying to join them into a long string with a spacer between. But I am having trouble getting the value of the array. Better exp...

Issue getting and storing memory address in array

So, I'm having a bit of pointer issues. I'm writing a function that stores memory addresses in a[]. These memory addresses point to actual data values in b[]. I'm having trouble getting the memory address from b to store in a. // Assume these are initialized to 0 outside of this snippet char a[100]; char b[100]; b[0] = 42; // Some valu...

idea to add javascript array to database using PHP

i need to push data in javascript array into database using PHP first i have multidimentional array in js. Brady [0] [0] = "1"; Brady [0] [1] = "Carol"; Brady [1] [0] = "2"; Brady [1] [1] = "Jan"; Brady [2] [0] = "3"; Brady [2] [1] = "Mike"; and i have table in database such as (id, name) second if i need to delete some rows in arra...

array sorting error unknown cause

hello i have this array that compares two arrays to see if it contains an object however after testing it with nslog NSLog (@"1"); favoritesArray = [[NSMutableArray alloc] init]; NSLog (@"2"); //Add items // favoritesArray = [[NSMutableArray alloc]init]; didContain = [[NSMutableArray alloc]init]; NSLog (@"3"); if ([favoritesArray cont...

Find Range of a number from an array.

I'm just rephrasing the question I asked a little while ago. I have a sorted array {2.0,7.8,9.0,10.5,12.3} If I given an input 9.5 What is the fastest way to find 9.0 and 10.5 to indicate that 9.5 is in between 9.0 and 10.5 (9.5 >=9.0 and <10.5) ? Is binary search an option?But since the input need not be in the array.I'm not sure how I...

How to fetch textbox array value using javascript/jquery

I have an array of text inputs like this: <input type="textbox" name="mobileno[]"><br> <input type="textbox" name="mobileno[]"><br> <input type="textbox" name="mobileno[]"><br> They are generated at run time using an "add more" button. Is there a way I can use jQuery to fetch the text input value and pass it in ajax request? I have...

C: declare a constant pointer to an array of constant characters

Hi, I am trying to understand array declarations, constness, and their resulting variable types. The following is allowed (by my compiler): char s01[] = "abc" ; // typeof(s01) = char* const char s02[] = "abc" ; // typeof(s02) = const char* (== char const*) char const s03[] = "abc" ; // typeof(s03) = char const* (== const char...