arrays

Converting a flat array to a nested array

Hi, I am trying to convert a flat array to a nested array depending on the 'level' data of each array item. 'level' data shows us if current array item is a child, a parent or a sibling. Here is the flat array: $flatArray = array( array('title'=>'Page 1', 'level'=>0), array('title'=>'Page 2', 'level'=>0), array('title'=>'P...

Blackberry Development, adding dynamic number of buttons and setting Fieldchangelistener() for them

Hi, I am adding dynamic number of buttons in a Blackberry application and trying to get different events on each button click. I am not able to apply the setchangelistener() for these array of buttons as once the loop finishes after adding all the buttons, the events gets generated only for the last indexed button. If I make us of getI...

Prototype.js: How can i return an array without all the methods Prototypes extends Array with?

Hi! Is there a way to return a new version of an array/hash that does not contain all the methods/functions that prototype extends the array object with? Example: var myArray = $A(); myArray['test'] = '1'; myArray['test2'] = '2'; var myVariableToPassToAjax = myArray; If I debug myVariableToPassToAjax it looks like this: Array ( ...

duplicate one element from php array

how i can duplicate one element from array: for example, i have this array: Array ( [LRDEPN] => 0008.jpg [OABCFT] => 0030.jpg [SIFCFJ] => 0011.jpg [KEMOMD] => 0022.jpg [DHORLN] => 0026.jpg [AHFUFB] => 0029.jpg ) if i want to duplicate this: 0011.jpg , how to proceed? i want to get this: Array ( [LRDEPN] ...

Declaring a string array in class header file - compiler thinks string is variable name?

Hey everybody, I need a bit of a hand with declaring a string array in my class header file in C++. atm it looks like this: //Maze.h #include <string> class Maze { GLfloat mazeSize, mazeX, mazeY, mazeZ; string* mazeLayout; public: Maze ( ); void render(); }; and the constructor looks like this: //Maze.cpp #include...

I want to move 1 array to another in C#

Hi, This is just a quick question in C#. I have a scenario where I am working with several devices that all have slightly different data to work with. When I work out which device I am using, I want to set up a common array to use throughout the code, say arrayCommon. So I want to move the info from device1 to the common array. Do I ...

php foreach getting values from an array

I am having trouble accessing the values in an array, the array looks like this, Array ( [0] => Array ( [id] => 1661 [code] => 849651318 [job_status] => 4 [looking_for] => Lorem ipsum [keywords_education] => Derby University [sector_id_csv] => 10,21,9,...

Is it wise to call array.splice() whenever a row is clicked in a grid

I need to keep track of indexes/rows that are selected. When a row is selected in a jqGrid, I have an event splice an array - add if selected, remove if deselected. Is this wise? I just have a "doesn't seem like a good idea" feeling, so I'm really just looking for some validation one way or another :). ...

Is there a Bioperl equivalent of IO::ScalarArray for array of Seq objects?

In Perl, we have IO::ScalarArray for treating the elements of an array like the lines of a file. In BioPerl, we have Bio::SeqIO, which can produce a filehandle that reads and writes Bio::Seq objects instead of strings representing lines of text. I would like to do a combination of the two: I would like to obtain a handle that reads succe...

How to convert JavaScript literal into JSON array?!

Possible Duplicate: How to count JavaScript array objects? If it's not a JavaScript array, so how to convert it into JSON array? var member = { "mother": { "name" : "Mary", "age" : "48" }, "father": { "name" : "Bill", "age" : "50", "friend": { "co-worker" : "Jake" ...

java recursion on array

I have to create a program that finds all the possible ways of filling a square of size x by y. You place a block which takes up 2 spaces to completely fill. The problem is I don't know how to code it to the point where you can remember the placements of each square. I can get it to where it fills the board completely once and maybe tw...

Whats the most elegant way to rearrange an associative array?

Suppose you have an associative array $hash['Fruit'] = 'Apple'; $hash['Name'] = 'Jeff'; $hash['Car'] = 'Ford'; and you cannot change the order in which these variables are created. So Car is always added to the array after Name, etc. What's the prettiest way to add/move Car to the beginning of the associative array instead of the end ...

Multi-Array of XML Requests

OMG, I am in need of a way to set up arrays of XML Requests based on the idShout - 1. So it would be something like this... var req = new Array(); req[idShout - 1] = ALL XML Data... Here's what I got so far but it's not working at all :( var idShout; var req = new Array(); function htmlRequest(url, params, method) { req[req.pus...

Array/list vs Dictionary (why we have them at first place)

To me they are both same and that is why i am wondering why we have dictionary data structure when we can do everything with arrays/list? What is so fancy in dictionaries? ...

Xcode Obj-C: Make new NSArray from one key each out of an Array of Dictionaries

This actually could be a multipart question. But here's the first part ... I have an array (actually in a plist) of dictionaries. Each dictionary has 3 keys in it: (title), (points), and (description). I am trying to make a NEW array with the values of the key "title" from each dictionary in that first array. Let me explain WHY I a...

removing pairs of elements from numpy arrays that are NaN (or another value) in Python

I have an array with two columns in numpy. For example: a = array([[1, 5, nan, 6], [10, 6, 6, nan]]) a = transpose(a) I want to efficiently iterate through the two columns, a[:, 0] and a[:, 1] and remove any pairs that meet a certain condition, in this case if they are NaN. The obvious way I can think of is: new_a = [] fo...

jQuery.Ajax makes the wrong request with array data

Hello, I have the following array: var idParam = ["1","2","3"]; I want to send this data as request using jQuery.ajax, what I'm doing: $.ajax({ type: "GET", url: "Services/GetInfo.ashx", data: { "id": idParam }, contentType: "application/text", dataType: "json", success: functio...

Retrieving data from enumerated JSON sub arrays in Javascript without getJSON

I'm new to JSON and ajax, but i'm trying to access data in an array where the items are enumerated in a sub array within another sub array. I run into problems with I try to access something like data.items[0].details.specs[1].name data.items[0].details.specs[1].id data.items[0].details.specs[2].name data.items[0].details.specs[2].id et...

Can I use "map" as a substitute for "for each"/"for in"?

For a little while now javascript has the "map" function to loop over arrays. It appears possible to use it as a 'foreach' operator for example: fruitbowl.map(function(fruit){ ... do stuff with fruit }) Is this better or worse than saying for(var i in fruitbowl){ ... do stuff with fruitbowl[i]...

How to sort multiple arrays in PHP

hi, i have wrote a script to produce an array of data but now want to display in order of score. The array outputs as follows; [display_name] => Array ( [0] => ACT_Web_Designs [1] => user1_design [2] => user2_design ) [proffesion] => Array ( [0] => Web Developer [1] => web developer ...