arrays

jquery ajax is converting ruby objects array into has.

So I have this weird problem with jquery doing a ajax post with a ruby object. I have 2 options. 1. $('form_id'}.serialize(). I know this works. But my form simply has too many fields, and it is a little too inconvenient to manage them in the form 2. Second option, the rails controller is constructing a ruby object along the way as the f...

jQuery create an array of objects with a specific class

Is there an array created somewhere of all the objects with a specific class? I want to find the sixth div with class="clCategory". Is there something like: $('.clCategory:sixth').css(...); or $('.clCategory')[6].css(...); Or do I have to create the array at the same time I programmatically create each of the DIVs with class="cl...

What's a quick way to convert a List<List<string>> to string[][]?

.ToArray doesn't do it ...

CSV into array in C.

Hi there, I'm trying to load a CSV file into a single dimentional array. I can output the contents of the CSV file, but in trying to copy it into an array I'm having a bit of trouble. Here is my existing code, which I realise is probably pretty bad but I'm teaching myself: #include <stdio.h> #include <string.h> #define MAX_LINE_LENGT...

Can Lucene in Zend search an array with data, and return a stripped array?

I've got an array with data. For example $data = array( 'test', 'test2', 'tost', 'testing', 'another', 'search' ); I wanna do a search on this array. lets say "test~" with lucene. I would for that way want to have the first 5 results in the array, and as feedback i need an array with those 5 items. Is this poss...

PHP: dynamically find key position in multidimensional array

I have already posted a similiar question to this one some time ago, but now it's different, so please don't close this as a duplicate. I have a multi-dimensional array. I want a function that finds the position of the given array key (all my array keys are strings) and then returns the position of the key in the array, AS an array. He...

Why Array.length does not work with key string

I've been reading and doing some testing and found that the command. "Length" of the Array () javascript does not work when the array's keys are string. I found that to run this command, I use whole keys. However, I wonder if any of you can tell me why this rule? Limitation of language, or specification of logic? Or, my mistake ...? Th...

How do I load custom configuration files with codeigniter?

Hey all, I've just started to use codeigniter and I have a question. I am using arrays for defining certain values like: $gender = array ('male','female'); Or: $maritalStatus = array ('married', 'single', 'divorced'); I am using these kind of arrays in different views. My question is, is there a chance to put all of these arra...

PHP - SPL vs array:: When should we use SPL and when we should use array in php5?

Hi, In java and C++ when we dont know the size - array not used like in php, instead used linkedList etc.. In php exist SPL, but most of the times programers use array, why(because peaple don't know about spl )? When we should use in php5 array and when SPL and what the difference in this case between PHP and Java/C++? Thanks ...

Order an array using another array as indexes C#

Hi, so if I have an array of characters char[] chars = new char[]{'f','a','d','e','c','b'}; and another array of integers that say what the sort order is: int[] sortOrder = new int[]{5,1,4,5,3,2}; how could I sort the data in the chars array, using the values in the sortOrder array to determine the order? In the above example, the...

Java: Sorting multiple ArrayLists synchronously or a single mapped ArrayList

I've only started learning Java about 3 months ago and this is my first post here, so please bear with me. I have multiple ArrayLists built from parsed XML that are directly related to each other in order. The arrays are later put into a single mapped ArrayList (groupData) to be read with a SimpleAdapter which creates the list in the An...

How can I transform or copy an array to a linked list?

I need to copy an array to a linked list OR transform the array in a linked list. How this can be done in .NET (C# or VB)? Thanks ...

PHP Array manipulation

I have an array like this: [0] => Array ( [slideritem] => 592 [sliderbig] => 644 ) [1] => Array ( [slideritem] => 593 [sliderbig] => 645 ) [2] => Array ( [slideritem] => 594 [sliderbig] => 646 ) slideritem is the id of an image that will be displayed and the sli...

object vs object[]

I am looking at a method that takes a parameter of object[]. But if I pass in a single value (ie an object) it still works. Is this built in as part of C#? Are object and object[] the same? I ask, because sometimes I need to pass in an array of objects and sometimes I need just one and I am wondering if I need to do this: public sta...

Generating Combinations in python

I am not sure how to go about this in Python, if its even possible. What I need to do is create an array (or a matrix, or vector?) from 3 separate arrays. Each array as 4 elements as such, they return this: Class1 = [1,2,3,4] Class2 = [1,2,3,4] Class3 = [1,2,3,4] Now what I would like to do is return all possible combinations of thes...

Variable value as part of array key

$pname = "postback_".$data; $_SESSION["$pname"] = $data; It is not working. How to use it? ...

Pairing array elements in ruby

Let's say i have an array called teams. I want to plan matches for every team with every other team. This is almost what i want except that same matches are added twice: teams.each do |red_team| teams.each do |blue_team| if red_team != blue_team @planned_matches << Match.new(red_team, blue_team) end end end How to d...

Add some new data into an Array in PHP

Hi all, I got an Array like this: array('Testing'=>array( 'topic'=>$data['Testing']['topic'], 'content'=>$data['Testing']'content']) ); Now I have got some new data to add into the Array shown aboved, how can I do it so that the new Array will look like this: array('Testing'=>array( 'topic'=>$data['Testing']['topic'],...

how to sort a ruby array of strings by length

How do I sort this: arr = ["aaa","aa","aaaa","a","aaaaa"]; into this arr = ["a","aa","aaa","aaaa","aaaaa"]; ...

incorrect use of ruby's sort_by function

My sort function is clearly not working, I am trying to sort ALL_VIEWS by @permalink.length: ALL_VIEWS.sort_by {|view| view.permalink.length} ALL_VIEWS[0..4].each do |view| puts view.inspect puts view.permalink.length end this produces: #<View:0x1014da7b8 @permalink="xxxx"> 4 #<View:0x1014da790 @permalink="yyyyy"> 5 #<View:0...