arrays

Asp.net Mvc: Jquery post array + anti forgery token

Hello, how do I post an array to an action on my controler with the anti forgery token. This is my Jquery postdata: var postData = { '__RequestVerificationToken': $('input[name=__RequestVerificationToken]').val(), 'productIds': IDs }; this is my Jquery post: $.post("MyProducts/DeleteProduct" , postData, function(data) { }); This i...

Can PHP arrays do this?

lets say; I have a $friends array with 2,000 different friendID numbers + I have a $bulletins array with 10,000 bulletinID numbers, the $bulletins array will also have another value with a userID of who posted the bulletin entry Now is it possible to get all the bulletinID numbers that have a userID matching a userID in the friends a...

JavaScript - Getting a name of an element in associative array

I have a JavaScript object that is treated as an associative array. Let's call it "fields". It has several elements, e.g.: fields['element1'] = ... fields['element2'] = ... fields['element3'] = ... Given fields[0], is it possible to obtain the name of the property (which is "element1") instead of its value? ...

How do I select 10 random things from a list in PHP?

I know how to select one random item from an array, but how about ten random items from an array of, say, twenty items? (In PHP.) What makes it a little more complicated is that each item actually has two parts: a filename, and a description. Basically, it's for a webpage that will display ten random images each time you reload. The act...

"Cut" an element by its key from an array

I've got an indexed array with n elements: Array( 'key1' => 'value1', 'key2' => 'value1', 'key3' => 'value1', ... 'key<i-1>' => 'value<i-1>', 'key<i>' => 'value<i>', 'key<i+1>' => 'value<i+1>', ... 'key<n>' => 'value<n>' ) How to "cut" (ie: copy + remove) the i_th element so the resu...

Nested arrays in Objective-C ( NSMutableArray )

Hi, I'm trying to build a nested array: First, I make a "PlayerItems" array which will contain 10 arrays, each containing item objects, corresponding to the inventories of each player in the game. On the indicated line, I get the following error: error: void valued not ignored as it ought to be What is the void value here? If I use...

C#: Is it possible to store a Decimal Array in an SQL database?

Hi there, I'm working on an application for a lab project and I'm making it in C#. It's supposed to import results from a text file that is exported from the application we use to run the tests and so far, I've hit a road block. I've gotten the program to save around 250 decimal values as a single-dimension array but then I'm trying to...

JTextfield array help

I have been trying to create a JFormattedTextField array which populates in a pane. Once a click event occurs, the actions get processed and the textfields are populated using setText(). The code for the array and initializing is in the constructor method here: JFormattedTextField[] balance=new JFormattedTextField[360]; JFormattedText...

How to generate a random number with Java from given list of numbers.

Hi, Assume I have an array/vector of numbers like 1,3,7,9 then I need to guess a number from this list randomly. Using Random class in Java it seems like not possible to do this. Could anyone kindly help me to tell a way to do this kind of thing. I have to change the list of numbers used to generate random number. I am trying to impleme...

How to remove duplicated 2-dimension array in PHP?

I got some idea from the posts before are talking about making a hash value on for each $array[$i], and then compare the hash to get the unique array, but I don't know what exactly I can do. My sample array Data: $arr[] = array(0,1,2,3); $arr[] = array(4,5,2,1); $arr[] = array(0,0,0,0); $arr[] = array(0,1,2,3); I expected to return ...

Looping through all instances of a javascript object

Hi, if I have an object constructor like: function cat(color, sex){ this.color = color; this.sex = sex; } and I make some cats: var fluffball = new cat("blue","male"); var shiznitz = new cat("red","male"); var slothersburger = new cat("green","female"); Is it possible to loop through all the cats I have declared? Somethin...

How to put std::dec/hex/oct into a look-up array

Hello. I have this generic string to number conversion : enum STRING_BASE : signed int { BINARY = -1, OCTAL = 0, DECIMAL = 1, HEX = 2, }; template <class Class> static bool fromString(Class& t, const std::string& str, STRING_BASE base = DECIMAL) { if (base == BINARY) { t = (std::bitset<(sizeof(unsigned long)*8)>(str...

Arrays.asList() of an array

Hi! My question is: what is wrong with this conversion? public int getTheNumber(int[] factors) { ArrayList<Integer> f = new ArrayList(Arrays.asList(factors)); Collections.sort(f); return f.get(0)*f.get(f.size()-1); } I made this after reading solution found in http://stackoverflow.com/questions/157944/how-to-create-array...

How to get linq result as string array?

Hi I would like to convert a list of User's properties into strings array (for json receiver) like: List<User> users = <..list of users from db...> var jsonData = ( from user in users select new { user.Id, user.Person.Lastname, user.Person.Firstname }); return Json(jsonData) The result is an array named fields [{"Id":1,"Lastn...

Find length of initial segment matching mask on Arrays

Given an array with n values, for example: $arr[] = 'ABCDEFABC'; $arr[] = 'ABCDEFDEF'; $arr[] = 'ABCDEFGHI'; $arr[] = 'ABCDEFJKL'; how can I find the initial segment that matches all (or most, in the example bellow) values, in this case ABCDEF? EDIT 2: NOT SOLVED, SEE ANSWER. Even worse, given the following array: $arr[] = 'ABCDEFA...

Trouble converting a byte array on the iphone...

I'm having a little dilemma with an iphone project. I'm getting some JSON data from a webservice. I can deserialize it into a dictionary OK. One of the dictionary values is a binary (a picture), but my JSON library deserializes it as an NSArray of NSDecimalNumbers! How do I convert this NSArray of NSDecimalNumbers to an NSData object, ...

Efficient container for bits

I have a bit array that can be very dense in some parts and very sparse in others. The array can get as large as 2**32 bits. I am turning it into a bunch of tuples containing offset and length to make it more efficient to deal with in memory. However, this sometimes is less efficient with things like 10101010100011. Any ideas on a good w...

how to find a variable is a type of array

How to find a variable is of type array in cakephp? thanks ...

how to fetch array keys with jQuery?

Good afternoon. I have an array with some keys, and values in them. I then need to fetch the array keys and not the data in them. I want to do this with jQuery. I know for example that PHP has a function called array_keys(); which takes the array as a parameter and gives you an array back with each key in each index. This is what I came...

create an array from a txt file

hey guys, I'm new in python and I have a problem. I have some measured data saved in a txt file. the data is separated with tabs, it has this structure: 0 0 -11.007001 -14.222319 2.336769 i have always 32 datapoints per simulation (0,1,2,...,31) and i have 300 simulations (0,1,2...,299), so the data is sorted at first with the numbe...