arrays

What is wrong with this php array?

$canada_territories = array("British Columbia" => "British Columbia", "Manitoba" => "Manitoba", "New Brunswick" => "New Brunswick", "Newfoundland and Labrador" => "Newfoundland and Labrador", "Nova Scotia" => "Nova Scotia", "Northwest Territories" => "Northwest Territories", "Nunavut" => "Nunavut", "Ontario" => "Ontario", "Prince Edward...

How do I make a button play sounds in a certain order using an array?

I'm coding in Objective-C for the iPhone and I am trying create an array that plays a series of sounds. For example the first time I press the button I want it play sound "0.wav", but the second time I want it to play "1.wav", then "2.wav", "3.wav", etc. Then when I've played a total of 14 sounds (up to "13.wav") I want the loop to star...

Passing a sub array as an array in C#

This is an easy one, I am sure, but I can't seem to find it on google. If I have a function: foo(int[] a) {} and I want to call it with a subarray of an array: for instance: myNums[3]+ (i.e. an array {4,5,6}), given myNums: int[] myNums = { 1,2,3,4,5,6}; Of course, I don't want to create a new array of just those sub items. I cer...

How can I protect part of an array in php from being modified?

I have an array in php like this: $myArray = array('name'=>'juank', 'age'=>26, 'config'=>array('usertype'=>'admin','etc'=>'bla bla')); I need this array to be accesible along the script to allow changes in any field EXCEPT in the "config" field. Is there a way to protect an array or part of an array from being modified as if it where d...

Sort an array of strongly typed objects based on a property of the object C#

Possible Duplicate: How to sort an array of FileInfo[] C# Duplicate of How to sort an array of FileInfo[] C# I have an array[] of objects, for certain reasons I cannot change it to a List<>, is it possible to sort on the array[] of objects, based on a value in 1 field of the object? For example arrayOfFruit[] fruit; fruit.s...

PHP - Array search for multiple values

I need to get the keys from values that are duplicates. I tried to use array_search and that worked fine, BUT I only got the first value as a hit. I need to get both keys from the duplicate values, in this case 0 and 2. The search result output as an array would be good. Is there a PHP function to do this or do I need to write some mul...

PHP Is there anyway I can simulate an array operator on the return value of a function

In C# and other languages, I can do something like this $value = $obj->getArray()[0]; But not in PHP. Any workarounds or am I doomed to do this all the time? $array = $obj->getArray(); $value = $array[0]; ...

Making a Javascript array of multiple CSS classes assigned to an element with jQuery

MY javascript: Updated Again. $('.calc').change(function(){ var classArray = $(this).attr('class').split(','); $.each(classArray, function(){ alert(classArray); }); }); And the input: <input type="text" class="calc R#r# C#i#" /> The pound signs are variables, I'm using ColdFusion. What I need to be able to do ...

Ruby on Rails : Cannot access an object's attributes in an array

Hello, I am building a site with works and their credits. What I am trying o achieve is to find each work's similar works based on the mutual titles in their credits. I am adding each similar work into an array in a for loop and when I try to access the attributes of these works I get a "nil object when you didn't expect it!" error. I...

What's it called when you cast an array of objects to an array of strings?

There's a special name for it, but I can't remember what it is. There are two different terms, one for casting an array of a subclass to an array of its superclass, and the other way around. ...

counting duplicate entries in Data base

I want to count the amount of times that a zip code is entered into a database. I'm not sure if I am using the right function or not. Also eventually I need to separate the zip codes by the year they were entered int the data base. I know how to separate the years-I think. What I really need help on is counting duplicate entries Here is ...

Even more lost than before - stumped with a PHP loop

Okay, so I followed the advice on this question: http://stackoverflow.com/questions/1214176/stumped-in-the-middle-of-a-php-loop But now, I'm having even more problems than before. Here's what I have so far: $sql = "SELECT section_name, category_name, result_level, url, winner FROM 2009_RKR_bestof INNER JOIN categories ON 2009_RKR_best...

SQL SELECT Arrays in C#?

Possible Duplicate: Is it possible to send a collection of IDs as a ADO.NET SQL parameter? Duplicate: this is a duplicate of Is it possible to send a collection of ID’s as a ADO.NET SQL parameter? and many others. Please vote to close it and add any additional answers to one of the other duplicates. Given an array of parameters...

Storing Values in an Array of Structures

How do I store values in an array of structures? MydatainfoArray is the array of the structures, and here is how I get the values using the function SDK_Get: MydatainfoArray Mydtinfo = new MydatainfoArray(); IntPtr MyinfoBuffer = IntPtr.Zero; int FIN = Marshal.SizeOf(Mydtinfo); MyinfoBuffer = Marshal.AllocCoTaskMem((int)FIN); Marsh...

How to set up single array or dictionary for use in multiple datasources?

I have multiple TableViewDatasources that need to display list of objects form same pool depending of certain property. E.g. object.flag1 is set- it will show up in TableView1 object.flag2 is set- it will show up in TableView2 The obvious way would be to have separate arrays for each TableView, But same object may appear in different...

How to check if a certain part of the array exists in another array?

I have an two associative arrayes and I want to check if $array1["foo"]["bar"]["baz"] exists in $array2["foo"]["bar"]["baz"] The values doesn't matter, just the "path". Does array_ intersect_ assoc do what I need? If not how can I write one myself? ...

Why is first value of captured expression getting stored in fourth element in Perl?

I am storing information captured by regex into an array. But for some reason the first value is getting stored at 4 element of array. Any suggestion on whats going wrong and how to store the first value in the first element of array. The following is the script: #!/usr/bin/perl use strict; my @value; my $find= qr/^\s+([0-9]+)\s+([A-Z...

Keeping even numbered elements of an array ?

Say I have an $input array, that contains something like this : array 0 => string 'a' (length=1) 1 => string 'b' (length=1) 2 => string 'c' (length=1) 3 => string 'd' (length=1) 4 => string 'e' (length=1) 5 => string 'f' (length=1) 6 => string 'g' (length=1) 7 => string 'h' (length=1) 8 => string 'i' (length=1) 9 => ...

Create an associative array with dynamic keys in Actionscript 2

for an XML file, I want to create an array in actionscript where I can reference a particular value with a key I set rather than 0, 1, 2 etc buildings = myParsedObjectFromXML; var aBuildings = new Array(); for ( building in buildings ) { var currentBuilding = buildings[building][0]; var key:String = currentBuilding.buildingCod...

How do I access a string-indexed element of a PHP array?

I have the following array (in php after executing print_r on the array object): Array ( [#weight] => 0 [#value] => Some value. ) Assuming the array object is $arr, how do I print out "value". The following does NOT work: print $arr->value; print $val ['value'] ; print $val [value] ; So... how do you do it? Any insight i...