arrays

Returned AJAX array not being copied to array

I have simple AJAX function that uses jQuery to return an array of 300 test objects from a database. I can see the data is returned, and I can use FireBug to step through the first loop and step into the constructor. This data is copied to an JS array. The code fragment looks like: //retrieve star locations to display on page $...

Unsetting elements of a cakephp generated array

I have an array called $all_countries following this structure: Array ( [0] => Array ( [countries] => Array ( [id] => 1 [countryName] => Afghanistan ) ) [1] => Array ( [countries] => Array ( ...

In Java what do arrays inherit from? Can I do this?

Hi Sorry for the newbie question, I'm used to C# so my Java framework knowledge is not so good. I have a couple of arrays: int[] numbers = new int[10]; String[] names = new String[10]; //populate the arrays Now I want to make a generic function which will print out the values in these arrays, something like the following (this shou...

Convert Array to Object PHP

How can i convert an array like this to object? [128] => Array ( [status] => Figure A. Facebook's horizontal scrollbars showing up on a 1024x768 screen resolution. ) [129] => Array ( [status] => The other day at work, I had some spare time ) ) ...

Multiplying two number arrays

Can anyone please tell me how to multiply two number arrays in C? The number arrays are basically derived from two strings containing digits. eg: 123456 and 132465. Edit: I had two string as S1 = "123456" and S2="132546". I then converted these two strings into array of ints i.e. int IS1[6] and IS2[6] so that IS1[1] = 1, IS1[2] = 2......

Casing an Array with Numeric Keys as an Object

I was poking around PHPs casting mechanism, and ran into an odd case when casting an array as an object $o = (object) array('1'=>'/foo/bar'); $o = new stdClass(); var_dump($o); As I understand it, PHP properties need to be declared with the same rules as PHP variables. That is A valid variable name starts with a letter or underscore...

Sorting a table in PHP

Hi, I have some difficulty sorting my array. It looks like this : [0] => Array ( [firstname] => Jnic [lastname] => Fortin [points] => Array ( [id] => 20453 [f] => 31 [r] => 7 [tota...

Deep copy of 2D array in Scala?

How do I do a deep copy of a 2D array in Scala? For example val a = Array[Array[Int]](2,3) a(1,0) = 12 I want val b to copy values of a but without pointing to the same array. ...

PowerShell: how *exactly* does the RHS of the -f operator work?

Last time I got confused by the way PowerShell eagerly unrolls collections, Keith summarized its heuristic like so: Putting the results (an array) within a grouping expression (or subexpression e.g. $()) makes it eligible again for unrolling. I've taken that advice to heart, but still find myself unable to explain a few esoterica. ...

Javascript splice not splicing

tl;dr; Even without my explanation one can look at the code below and the output and see something is fishy. Splice returns the index it spliced but the data remains in the array. So I have an object that's keyed almost like an array (0,1,2,3...etc). Each object key has an array value. The array is an array of objects. Here's a simp...

Are the SetValue/GetValue methods of System.Array thread-safe?

We had a little discussion in the office, and got no documented answer: Is System.Array.SetValue thread safe? using System; using System.Text; using System.Threading; namespace MyApp { class Program { private static readonly object[] arr = new object[3]; static void Main(string[] args) { st...

Size of an array

This question is about C++ I always thought that name of an array in C++ is only a pointer, so I thought that int ar[10]; cout << sizeof(ar); will give me the same as sizeof(int *). But it gives 40 - so it is real size of whole array. It also gives 40 when array size is given by variable: int n = 10; int ar[n] I want to copy a cla...

How does one specify a parameter as an array of a copied type?

I have a function that I am using as a sproc. For the parameters, I have one which is the primary key of a record in a particular table. I would like to modify this function so that it takes an array of such keys but I am struggling to find any material that specifies how this is achieved (or whether it is even possible). CREATE OR RE...

Homework: can you help me to answer for this question about array?

Suppose that temperature measurements were made on 7 days of 2009 in each of 5 cities .write a program that will read the city name followed by the temperature measurements of that city.The city name and measurements should be stored in two array .The program should find out the average temperature of each city.Also you should find the ...

PHP: Case-insensitive "array_diff"

I have following two arrays and the code to find array_diff: $obs_ws = array("you", "your", "may", "me", "my", "etc"); $all_ws = array("LOVE", "World", "Your", "my", "etc", "CoDe"); $final_ws = array_diff($all_ws, $obs_ws); Above code giving output array as: $final_ws = array("LOVE", "World", "Your", "CoDe"); But I want it as: $f...

ActionScript 3 Vector.<T> VS. Array

This question if a bit off topic, I just wanted feedback from most ActionScript/Flex developers out there. So would you use a Vector. rather than an Array when you're expecting a collection of the same "type" of objects (and publishing for fp10) Let me clear that out : I'm defining a method in a class that expects one parameter of ty...

Filter an array of hashes within a hash in ruby/rails

I'm aggregating RSS feeds using FeedTools. I followed this tutorial: http://simonwoodside.com/weblog/2008/12/7/ruby%5Fon%5Frails%5Ffeedrss%5Faggregator/ and everything functioned fine. The problem is I want to filter some of the hashes that exist within the array [:items] from inside the parsed feed hash. Here's the RSS cached feed obj...

create js array dynamically?

how could I declare several js array dynamically? For example, here is what tried but failed: <script type="text/javascript"> for (i=0;i<10;i++) { var "arr_"+i = new Array(); } Thanks! ...

how to construct a json object using info from several javascript arrays

I have two js arrays already, say: names and values (with the same length), now I would like to construct a json object in certain format? For example: names = ["label1","label2","label3"]; values = [[[0,1],[1,9],[2,10]],[[0,89],[1,91],[2,1]],[[0,1],[1,9],[2,10]]]; I would like to have a json array data_spec in this format: [{ ...

Struct array never receives items, but the method says it did

Yet another one of my idiotic P/Invoke questions... Sometimes I think this stuff is going to be a piece of cake, but it blows up in my face. I have a simple unmanaged method that takes a destination array and fills it. unsigned short NvtlCommon_GetAvailableDevices(SdkHandle session, DeviceDetail * pDev_list, unsigned long * dev_l...