arrays

jQuery Javascript array 'contains' functionality?

I'm trying to use the jQuery $.inArray function to iterate through an array and if there's an element whose text contains a particular keyword, remove that element. $.inArray is only returning the array index though if the element's text is equal to the keyword. For example given the following array named 'tokens': - tokens {...} ...

C Allocating Two Dimensional Arrays

I am trying to allocate a 2D dimension array of File Descriptors... So I would need something like this fd[0][0] fd[0][1] I have coded so far: void allocateMemory(int row, int col, int ***myPipes){ int i = 0,i2 = 0; myPipes = (int**)malloc(row * sizeof(int*)); for(i = 0; i < row;i++){ myPipes[i] = (int*)ma...

PHP - Checking whether a string exists in an entire array?

Hi all, Basic array question: $string = "The quick brown cat"; $check1 = "apple"; $check2 = "ball"; $check3 = "cat"; if ( (stripos($string, $check1) === false) || (stripos($string, $check2) === false) || (stripos($string, $check3) === false) ) { echo "Fail"; } How do I condense the above using an array ($check[])? ...

Order Multidimensional Arrays PHP

Hi everyone I have some problem to order an array by a field of this, here i leave the example foreach($xml as $site){ echo '<div><a href="'.$site->loc.'">'.$site->loc.'</a>' .$site->padre.'</div>'; } Some times the filed $site->padre is empty but i'd like to order by $site->padre alphabetical i saw example with usort but i don't und...

Array of ArrayList Java

Hi, I am creating an PriorityQueue with multiple queues. I am using an Array to store the multiple ArrayLists that make up my different PriorityQueues. Here is what I have for my constructor so far: ArrayList<ProcessRecord> pq; ArrayList[] arrayQ; MultiList(){ arrayQ = new ArrayList[9]; pq = new ArrayList<ProcessRec...

jQuery: how to get all stylesheet classes+ids into an array

hi, i'm using a wysiwyg editor which has a .css applied - how can i get all its classes into a variable eg. allClasses = ['navi','main']? thx ...

initialize array to 0 in C

I need a big null array in C as a global. Is there any way to do this besides typing out char ZEROARRAY[1024] = {0, 0, 0, /* ... 1021 more times... */ }; ? ...

Finding out the common / uncommon elements between two Arrays in PHP

Consider I have two arrays: $friends = Array('foo', 'bar', 'alpha'); $attendees = Array('foo', 'bar'); Now I need to populate a new array $nonattendees which contains only the elements which are in $friends array and not in $attendees array. i.e, $nonattendees array should be populated with 'alpha'. Is there any in built array operat...

PHP FTP Upload thousands of files

Hi, I've written a small FTP class which I used to move files from a local server to a remote server. It does this by checking an array of local files with an array of files on the remote server. If the file exists on the remote server, it won't bother uploading it. The script works fine for small amounts of files, but I've noticed tha...

Find by values in JavaScript Array

I have such an array: arr['key1'] = true; arr['key2'] = true; arr['key3'] = true; ... arr['keyN'] = true; How to determine, have anyone key a "false" value? ...

Adding an Array inside an array in a PHP function

I have created a function in PHP that calls a webservice and parses through the result, assinging values to variables and returning them all as an Array. This all works perfectly, however I have come across a need to have an "array within my array" I am assigning values as below: $productName = $product->Name; $productID = $product->ID...

How can I compare arrays in Perl?

I have two arrays, @a and @b. I want to do a compare among the elements of the two arrays. my @a = qw"abc def efg ghy klm ghn"; my @b = qw"def ghy jgk lom com klm"; If any element matches then set a flag. Is there any simple way to do this? ...

Codeigniter - accessing variables from an array passed into a page.

Hello, I have a controller with an index function as follows: function index() { $this->load->model('products_model'); $data['product'] = $this->products_model->get(3); // 3 = product id $data['product_no'] = 3; $data['main_content'] = 'product_view'; //print_r($data['products']); $this->load->view('includes/te...

Evaluating Javascript Arrays

I have an array that contains an array of arrays if that makes any sense. so for example: [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]] I want to see whether an array exists withing the array, so if [1, 2, 3] is duplicated at all. I have tried to use the .indexOf method but it does find the duplicate. I have also tried Extjs to loop th...

PHP: separate value in array according to alphabate order

hi, i want to find values in array according to alphabate and want to make list in of array values according to alphabate order. my array is like that: Array ( [0] => Array ( [0] => Adidas [1] => AKG [2] => Apple [3] => Barrats [4] => Canon ...

Can I specify default value?

Why is it that for user defined types when creating an array of objects every element of this array is initialized with the default constructor, but when I create an array of a built-in type that isn't the case? And second question: Is it possible to specify default value to be used while initializing elements in the array? Something li...

Finding indexes of each element in a multidimensional array in ruby

Eg :a=[["hello", "world"], ["good", "lord"], ["hello", "lord"]] I need to find and record the indexes of each word with respect to the super-array. i.e hello => 0,2 world => 0 lord => 1,2. here's my shot ,but its very amateurish and lengthy. all_tokens=tokens.flatten all_tokens.each do|keyword| ...

php arrays next() and prev()

I have an array that looks like this, Array ( [0] => 849710414 [1] => 849710726 [2] => 849710744 [3] => 849712728 [4] => 849713005 [5] => 849713439 [6] => 849714856 [7] => 849714924 [8] => 849716371 [9] => 849716441 [10] => 849717118 [11] => 849719043 [12] => 849719187 [13] => ...

Deleted array value still showing up on foreach loop in AS3 (bug in flash?)

It took me many hours to narrow down a problem in some code to this reproducible error, which seems to me like a bug in AVM2. Can anyone shed light on why this is occurring or how to fix it? When the value at index 1 is deleted and a value is subsequently set at index 0, the non-existent (undefined) value at index 1 will now show up in ...

Question about memory allocation when initializing char arrays in C/C++.

Before anything, I apologize if this question has been asked before. I am programming a simple packet sniffer for a class project. For a little while, I ran into the issue where the source and destination of a packet appeared to be the same. For example, the source and destination of an Ethernet frame would be the same MAC address all o...