arrays

PHP compare array

Is there anyway to compare arrays in php using an inbuilt function, short of doing some sort of loop? $a1 = array(1,2,3); $a2 = array(1,2,3); if (array_are_same($a1, $a2)) { // code here } Well you get the idea :D ...

PHP arrays: extract one dimension

I have an array that looks like: $fields = array( "f1" => array("test"), "f2" => array("other" => "values") ); I'd like to retrive this information in one array: $first_dimension = array("f1","f2"); Is there a function in PHP that can extract a particular dimension of an array directly? Is there a syntax shortcut for this? ...

PHP: Getting array type

Is there a php function that someone can use to automatically detect if an array is an associative or not, apart from explictly checking the array keys? ...

Cocoa: I need help with some code?

Hello, I was going through some code that I downloaded off the internet (Got it here) I am confused with this line of code... What exactly is it doing? #define N_RANDOM_WORDS (sizeof(randomWords)/sizeof(NSString *)) Here is the array of "randomWords": static NSString *randomWords[] = { @"Hello", @"World", @"Some", @"Random", @"Word...

Linear Search in a Char Array -- C++ (Visual Studio 2005)

I am very new to C++ programming and you will see why. I want to make a character array consisting of a few words that I want to search with a linear search function. Does this array have to be a two-dimensional array? For example: char Colors[3][6] = {"red", "green", "blue"}; I tried it like this: char Colors[] = {"red", "green", "...

Sort arrays into multidimensional array by key

I have a database table which gives me the following result: array(8) { ["link_id"]=> string(2) "20" ["link_url"]=> string(56) "http://url.of/website" ["link_name"]=> string(34) "Website title" ["link_target"]=> string(0) "" ["link_description"]=> string(0) "" ["link_updated"]=> string(19)...

Get NSIndexSet from NSArray

NSArray has useful methods to find objects for specified indexes // To find objects by indexes - (id)objectAtIndex:(NSUInteger)index - (NSArray *)objectsAtIndexes:(NSIndexSet *)indexes // To find index by object - (NSUInteger)indexOfObject:(id)anObject However, I want to get NSIndexSet (multiple indexes) for given objects. Something ...

C#: Get which button was pressed in an array of gtk#-buttons?

I have an array of buttons which shall all call the same method but with the index of the button as an argument. using System; using Gtk; public class Input : Gtk.Window { private Gtk.Button[] plus; public Input() : base(Gtk.WindowType.Toplevel) { plus = new Button[10]; [...] for (uint i = 0; i < 10; i++) ...

Regex Search Help

Given a string such as: a:2:{i:0;s:1:"1";i:1;s:1:"2";} I want to find every integer within quotes and create an array of all integers found in the string. End result should be an array like: Array ( [0] => 1 [1] => 2 ) I'm guessing you use preg_match() but I have no experience with regular expressions :( ...

PHP/MYSQL using an array in WHERE clause

given an array $galleries = array ( [0] => 1 [1] => 2 [2] => 5 ) I want to have a sql query that uses the values of the array in its WHERE clause like: SELECT * FROM galleries WHERE id = //values of array $galleries... eg. (1 || 2 || 5) // How can I generate this query string to u...

In Cakephp, how can I access an array from the whole application.

In CakePHP, how can I make an array we use accessible by the whole application? Is there an equivalent of PHP's define() function? ...

Using strsep() with dynamic array of strings in C

I have the following code: #include <string.h> int main(void) { char *buffer = NULL, **words = NULL, *aPtr = NULL, *sPtr; int count = 0; buffer = strdup("The quick brown fox jumps over the lazy dog"); sPtr = buffer; do { aPtr = strsep(&sPtr, " "); words[count++] = ... // missing code } while(aPtr); ...

Reading from Excel (Range into multidimensional Array) C#

Hello, How would I read from an Excel sheet and load the marked selection (Area) into an multidimensional array? A column in Excel could itself be a multi dimensional array since it would contain more than just one value. The idea (not sure how good or bad this is) is right now is to do a for loop through all the Excel.Area (selected ...

an array question

Hi Guys i have an array below string stringArray = new stringArray[12]; stringArray[0] = "0,1"; stringArray[1] = "1,3"; stringArray[2] = "1,4"; stringArray[3] = "2,1"; stringArray[4] = "2,4"; stringArray[5] = "3,7"; stringArray[6] = "4,3"; stringArray[7] = "4,2"; stringArray[8] = "4,8"; stringArray[9] = "5,5"; stringArray[10] = "5,6";...

Declaring, Properties, Synthesizing, and Implementing int[] array in Objective C

How do you declare, set properties, synthesize, and implement an int array of size 5 in Objective C? I'm writing this code for an iphone app. Thanks. ...

How can I elegantly create a hash from an array reference in Perl?

Hi, I am looking for a more elegant way to create a hash that contains the list I have read in from my configuration file. Here is my code: read_config($config_file => my %config); my $extension_list_reference = $config{extensions}{ext}; my @ext; # Store each item of the list into an array for my $i ( 0 .. (@$extension_list_refere...

Ordering coordinates problem (QUESTION FROZEN)

Thanks for all your help on this question but your answers and thoughts have made us think about our problem even more and we cannot agree on what the problem criteria shoudld be - dont put any more answers for now - but watch this space and we will get back to you...Cheers Have been scatching my head about this - and I reckon it's simp...

Java: assign String[] array element to a String?

I'm pretty new at this, and this is probably a pretty obvious answer. In my csv script, i'm trying to figure out how to read a csv file using the CSVReader class and write to a new csv file. The error is telling me writeNext(java.lang.String[]) cannot be applied to (java.lang.String). I've tried using a direct assignment and getString...

How do I work with dynamic multi-dimensional arrays in C?

Does someone know how can I use multi-dimesional arrays using C? Is that possible? Thanks a lot... ...

Oracle Associative Array TYPE is not able to use in USING statement (If TYPE is declared within Package)

Hi All, If 'Associative Array variable' is declared globally, able to use that in OPEN CURSOR USING statement. If 'Associative Array variable' is declared within package, while use in OPEN CURSOR USING statement, getting compilation error. More details provided below I am storing some values in one Associative Array variable. Late...