arrays

in_array problem with $GLOBALS

Hi All, I have a $GLOBALS['plugins'] array. With these values: Array ( [0] => Array ( [0] => calendarFuncs/ [1] => calendar.php [2] => Calendar ) [1] => Array ( [0] => eventFuncs/ [1] => todo.php [2] => Projects ) [2] => Array ( [0] => financeFu...

Why does C++ not support Variable-length arrays?

Possible Duplicate: Variable length arrays in C++? I am just curious, is there any particular reason why C++ does not allow variable length arrays? ...

Is it possible to detect the key for the array within the Rails params hash?

I'm using a inherited controller for an abstracted class. I'm trying to avoid overriding actions within all of the descendant controllers. How could I find out the name of the key where the array of form values is living? For example: The master class currently uses this to update rows if @parent.update_attributes(params[:parent]) ...

Declaring an array of negative length

What happens in C when you create an array of negative length? For instance: int n = -35; int testArray[n]; for(int i = 0; i < 10; i++) testArray[i]=i+1; This code will compile (and brings up no warnings with -Wall enabled), and it seems you can assign to testArray[0] without issue. Assigning past that gives either a segfault ...

How to create a method that can accept arraylist/collection of object - custom class type in actionscript

Like java, I want to create a method that accepts an array list of particular object type. In java: public void addStudents(List<Student> students) { ... } In actionscript public function addStudents(students:ArrayCollection):void { ..... } Here I want to have public function addStudents(students:ArrayCollection). Thanks ...

How to select unknown numbers in javascript?

So for example I have: array(2,1,3,4,5,6,7) and I already know (2,1,3) How should I get (4,5,6, 7) if I know that all numbers exists from 1 to 7 and the numbers what I already know So I want an array with the numbers what I don't know yet. Sorry if sounds stupid :| ...

How to get the item that appear the most time in an array?

var store = ['1','2','2','3','4']; I want to find out that 2 appear the most in the array. How do I go about doing that? ...

How can I easily remove the last comma from an array?

Let's say I have this: $array = array("john" => "doe", "foe" => "bar", "oh" => "yeah"); foreach($array as $i=>$k) { echo $i.'-'.$k.','; } echoes "john-doe,foe-bar,oh-yeah," How do I get rid of the last comma? ...

Why isn't my script processing all the elements in the array?

The following code is a test to test what I have already done with my new found knoledge of threads. #!/usr/bin/perl use strict; use warnings; use threads; use threads::shared; use URI; use URI::http; use File::Basename; use DBI; use HTML::Parser; use LWP::Simple; require LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->timeout(10); $...

php Get level array from Array Tree

Hello. I Have the next array: Array ( [1000] => Array ( [pv] => 81 ) [1101] => Array ( [1102] => Array ( [pv] => 33 ) [1103] => Array ( [pv] => 15 ) [pv] => 72 ) ) I want to make new array f...

How to get subset of two arrays in javascript?

What I am trying to do is if I have Array a = {1,2,3,4}; b = {1,2}; Then I want subset array as c = {3,4}; Can anybody help me? ...

Is it possible to create an array from existing array by pairing every two values into key and value?

This is what I want to do. I have an array. $arr = array('value1','value2','value3','value4','value5','value6'); Is it possible to pair every two values into something like: $new_arr = array('value1' => 'value2','value3' => 'value4', 'value5' => 'value6'); In the first array, there are no keys. They are all values. But I want to p...

Using PHP usort with conditional results

Long story short, I need to sort an array of objects using usort, and I need to tell usort which fields in the objects to sort by. The obvious solution is to create tens of separate usort sorting functions, but this seems sort of redundant and ugly. Most of the time, objects will be sorted by input from $_GET, but not always, so I don't...

C++ standard - how "array of unknown bound of T" is treated

Hi, I've got confused by the fact that this code works: struct S { char c[]; }; S s; According to C++ standard, chapter 8.3.4: "If the constant expression is omitted, the type of the identifier of D is “derived-declarator-type-list array of unknown bound of T”, an incomplete object type." But I cannot figure out how...

php sort array with preference

Hi, I have array and contains 50 values , example london,bluehit,green,lonpark,abc,aab,lonsee i want to sort as per my preference , i give one argument , example if i give arugment as lon then my array should form like london,lonpark,lonsee,aab,abc,blurhit,green,lonsee , so in the above my array output is i gave parameter as lon ...

What's a better way to save response sets in this situation?

I'm building a CLI survey app in Java that lets users answer multiple-choice questions. Please tell me how my approach can be improved. Each answer to a question is recorded as an int, which is the index of that choice in the array of choices for that question. All answers for a survey are saved as an int array. I'm thinking of seriali...

Finding object in array based on attribute

My app has the following models: user and watch_list. User has attributes id, name and WatchList has attributes user_id, friend_id. class WatchList < ActiveRecord::Base belongs_to :user has_many :friends, :class_name => "User", :foreign_key => "friend_id" end class User < ActiveRecord::Base has_one :watch_list has_many :friend...

how do I get array index number in php?

I'm sure this is a stupid question, but it's Friday and my brain just can't figure it out. I have an array of arrays, like so: $cart = Array ( [0] => Array ( [TypeFlag] => S [qty] => 2 [denom] => 50 [totalPrice] => 100 ) [1] => Array ( [TypeFlag] => V [qty] => 1 [denom] => 25 [totalPrice] => 25 ) ) I'm looping through this array...

Storing big int array partially in database , to reduce memory in java

Hi Experts, I have a class that has int[] members. The arrays grow very big, about 56M in size.(arrays are expandable with implementation similar to arraylist). Now I want to partially store the array in database, to improve memory. I have oracle database at my disposal. I would also like to cache more used indexes. I am wondering if ...

How do I remove elements at a set of indices in a vector in MATLAB?

I have a vector with 100 elements. I have another vector with index positions of elements I want to remove from this vector. How do I do this? ...