arrays

Fetch first element in 'new array' JSONP response with Jquery

I try to keep it simple: Problem: how to fetch the first element (weight here) from the new Array with JQuery Current JQuery: function xyz() { var the_url = 'http://longurl'+encodeURIComponent(searchBox.val()); var x1 = $.ajax({ type: "GET", url: the_url, ...

Immutable array in Java

Is there an immutable alternative to the primitive arrays in Java? Making a primitive array final doesn't actually prevent one from doing something like final int[] array = new int[] {0, 1, 2, 3}; array[0] = 42; I want the elements of the array to be unchangeable. ...

How do I sort a PHP array by an element nested inside?

I have an array like the following: Array ( [0] => Array ( 'name' => "Friday" 'weight' => 6 ) [1] => Array ( 'name' => "Monday" 'weight' => 2 ) ) I would like to grab the last values in that array (the 'weight'), and use that to sort the main arra...

Are Generic lists stored on the stack or the heap in C#?

Are Generic lists stored on the stack Or the heap? example //List of Ints List<int> myInts = new List<int>(); myInts.Add(5); myInts.Add(10); myInts.Add(20); Is myInts stored on the stack or the heap? If I add an int to the list, does boxing or unboxing occur? ...

Image handler in java write rgb values without using native java classes

I need to read an image pixel by pixel to obtain an array of RGB and write the image in shades of red, blue and green, but without using Image.io or specific java classes that handle and images ...

Remove "columns" from the subarrays of a two dimensional array

I have a simple, two dimensional array like this: Array ( [0] => Array ( [0] => abc [1] => 123 [2] => aaaaa ) [1] => Array ( [0] => def [1] => 456 [2] => ddddd ) [...

Defining a Static 2-dimension Array with Inline Function

I setup a class with: class Example { static const float array[3][8]; }; and implemented inline const float below_center(const float pos) { return pos - (size / 2); // size is a const float } inline const float above_center(const float pos) { return pos + (size / 2); } inline const float *set_pos(const float x, const fl...

How to obtain and push JSON data into Arrays? [AS3]

Hi Stackers, so I have a JSON link that contains a couple of nodes (not sure what you call them in JSON) that I need to put into arrays in ActionScript, but I'm still having trouble trying to trace out all the specific node content. I found a similar question here, but the fix just showed how to trace out the entire JSON file (which sho...

How can I print a Perl hash in specific order?

I have this code #!/usr/bin/perl use strict; my @a = ("b","a","d","c"); my %h = ("a",1,"b",2,"c",3,"d",4); #print '"' . join('","', @a), "\"\n"; print "\n"; foreach my $key (@a) { print '"' . $h{$key} . '",'; } print "\n"; that outputs "2","1","4","3", but I would like that it just outputted "2","1","4","3" Notice that la...

How to dynamically set array keys in php

I have some logic that is being used to sort data but depending on the user input the data is grouped differently. Right now I have five different functions that contain the same logic but different groupings. Is there a way to combine these functions and dynamically set a value that will group properly. Within the function these assi...

Struct with array member in C

Recently I reviewed some C code and found something equivalent to the following: struct foo { int some_innocent_variables; double some_big_array[VERY_LARGE_NUMBER]; } Being almost, but not quite, almost entirely a newbie in C, am I right in thinking that this struct is awfully inefficient in its use of space because of the arr...

Perl: Iterating through this funky array?

I'm trying to iterate over a 2D array that is structured in this specific way. Whether or not this is a good way to structure the array is another question - I still need to be able to iterate over it (if it is possible). @row1 = ( "Current Scan", "Last Month"); @row2 = ( "240", "0"); @row3 = ( "226", "209"); @row4 = ( "215", "207"); ...

Does a PHP array need to be declared before use?

While writing a recent application I accidentally started filling an array before I had declared it. error_reporting ( E_ALL); $array['value'] = 'Test string'; I use E_ALL error reporting and an error was not thrown. Is this correct? And if so, are there any issues with declaring array values whilst never declaring the actual array...

How to print an array of links in PHP

Need some php help in figuring out how use this array I created, but first of all I'm not sure if I done this right?? Its an array with names and href links that I would like to map for given server. Pls let me know if I constructed this properly: $server_array = array( 'server1.domain' => array( 'href' => 'https://ser...

Parse PHP Array from serialized data

I am using the jQuery plugin from http://mjsarfatti.com/sandbox/nestedSortable/ It does an excellent job on easily sorting the list, but I am having issues with saving it a DB and loading it back up. My question is once you get the array into PHP, serialize it and store it into a database, you end up with something along the lines of a...

How do I reference a nested array within my JSON data?

Hello, I need assistance in accessing a nested array located my JSON Data Set. Here is the first entry of my top-level JSON array: { "pingFeed": [{ "header": "Get Drinks?", "picture": "images/joe.jpg", "location": "Tartine's, SF", "time": "Tomorrow Night", "name": "Joe Shmoe", "pid": ...

MySQL query result split

This is somewhat of a multipart question, but.. I am looking to query a MySQL table to get fields from a event category table. Each category has a specific calendar assigned to it, in the "calendar" field in the category table. I am planning to have a HTML list box for each of the different types of calendars (only 4, and they wont ch...

How to manually initialize a collection of RECORDs in PL/SQL?

Hi, guys. Here's a simple sample two-dimensional array in PL/SQL, which is working perfectly. declare type a is table of number; type b is table of a; arr b := b(a(1, 2), a(3, 4)); begin for i in arr.first .. arr.last loop for j in arr(i).first .. arr(i).last loop dbms_output.put_line(arr(i) (j)); end loop; end ...

C++ Array of Objects

I have an array in a class that should hold some instances of other objects. The header file looks like this: class Document { private: long arraysize; long count; Row* rows; public: Document(); ~Document(); } Then in the constructor I initialize the array like this: this->rows = new Row[arraysize]; But for some...

how to build arrays of objects in PHP without specifying an index number?

Here is a weird question. I am building an array of objects manually, like this: $pages_array[0]->slug = "index"; $pages_array[0]->title = "Site Index"; $pages_array[0]->template = "interior"; $pages_array[1]->slug = "a"; $pages_array[1]->title = "100% Wide (Layout A)"; $pages_array[1]->template = "interior"; $pages_array[2]->slug =...