arrays

Sorting mysql array value after string chars swapped from fetched DB data.

I want to sort one column fetched from mysql DB, and stored in an array. After fetching I am doing below steps. DB Fetching fields array in row format. ->Field1, Field2, Field3, Field4, Field5 From that fields array One columns data [Field3], swapping string keywords. eg. AB013, DB131, RS001 should become: 013AB, 131DB, 001RS N...

Get second to last value in array

I'm frequently using the following to get the second to last value in an array: $z=array_pop(array_slice($array,-2,1)); Am I missing a php function to do that in one go or is that the best I have? ...

Get Video Links from Youtube Channel, extract video IDs from Urls and store them in an array

Hi there, This is my first question on this site. I'm new to php but i've followed advice and gotten my hands as filthy with it as possible. Unfortunately now I'm a little stumped with this simple Youtube app i'm trying to create. I know there are a several related questions out there, but i haven't yet found a comprehensive soluti...

Select Objects in Array Based on Regex Match

How can I return only the objects in an array that meet a certain criteria using javascript? For instance, if I have ['apple','avocado','banana','cherry'] and want to only output fruit that begin with the letter 'A'. EDIT: Took Sean Kinsey's function below and tried to make it more flexible by passing in the array and letter to match:...

Flex Tree with infinite parents and children

I am working on a tree component and I am having a bit of the issue with populating the data-provider for this tree. The data that I get back from my database is a simple array of value objects. Each value object has 2 properties. ObjectID and ParentID. For parents the ParentID is null and for children the ParentID is the ObjectID of th...

Searching through large data set

how would i search through a list with ~5 mil 128bit (or 256, depending on how you look at it) strings quickly and find the duplicates (in python)? i can turn the strings into numbers, but i don't think that's going to help much. since i haven't learned much information theory, is there anything about this in information theory? and si...

How does one wrap numpy array types?

I'd like to make a class extending the numpy array base type, class LemmaMatrix(numpy.ndarray): @classmethod def init_from_corpus(cls, ...): cls(numpy.empty(...)) But apparently, it will not allow multi-dimensional array types. Is there a way around this? Thanks in advance! ndarray(empty([3, 3])) TypeError: only length-1 arra...

Array within Form collecting multiple values with the same name possible?

Good afternoon, I will first start with the goal I am trying to accomplish and then give a very basic sample of what I need to do. Goal Instead of collecting several variables and naming them with keys individually, I have decided to give in and use an array structure to handle all inputs of the same type and rules. Once I have the va...

f# iterating over two arrays, using function from a c# library

I have a list of words and a list of associated part of speech tags. I want to iterate over both, simultaneously (matched index) using each indexed tuple as input to a .NET function. Is this the best way (it works, but doesn't feel natural to me): let taggingModel = SeqLabeler.loadModel(lthPath + "models\penn_00_1...

Comparing array of structs, and removing duplicate

I have two arrays of structs. array_of_structs1 array_of_structs2 The struct class looks like this, for contextual info: class Leader < Struct.new(:rank, :user); end I want to remove the duplicate users from array_of_structs1. Any assistance would be greatly appreciated! ...

Sum of a row of an associative array using PHP?

Is there a php function that returns the sum of a row of an associative array? If not should I just use a counter and a foreach loop? Appreciate it! ...

Send html array as post variable using Request.JSON

I have an html: First name: <input type='text' name='first_name' value='' /><br/> Last name: <input type='text' name='last_name' value='' /><br/> <input type='checkbox' name='category[]' value='Math' /> Math<br/> <input type='checkbox' name='category[]' value='Science' /> Science<br/> <input type='checkbox' name='category[]' value='Hist...

calculating min and max of 2-D array in c

This program to calculate sum,min and max of the sum of array elements Max value is the problem, it is always not true. void main(void) { int degree[3][2]; int min_max[][]; int Max=min_max[0][0]; int Min=min_max[0][0]; int i,j; int sum=0; clrscr(); for(i=0;i<3;i++) { for(j=0;j<2;j++) ...

Determining whether one array contains the contents of another array in ruby

In ruby, how do I test that one array not only has the elements of another array, but contain them in that particular order? correct_combination = [1, 2, 3, 4, 5] [1, 5, 8, 2, 3, 4, 5].function_name(correct_combination) # => false [8, 10, 1, 2, 3, 4, 5, 9].function_name(correct_combination) # => true I tried using include, but that is...

How can I use an array within a SQL query

So I'm trying to take a search string (could be any number of words) and turn each value into a list to use in the following IN statement) in addition, I need a count of all these values to use with my having count filter $search_array = explode(" ",$this->search_string); $tag_count = count($search_array); $db = Connect::connect(); $qu...

PHP code - what does this part of code mean?

what does the assignment in this loop do? I don't get the array notation in it :S foreach($fieldvalues as $fieldvalue){ $insertvalues[] = $fieldvalue; } ...

Passing an array as a function parameter in JavaScript

Hi all, i'd like to call a function using an array as a parameters: var x = [ 'p0', 'p1', 'p2' ]; call_me ( x[0], x[1], x[2] ); // i don't like it function call_me (param0, param1, param2 ) { // ... } Is there a better way of passing the contents of x into call_me()? Ps. I can't change the signature of call_me(), nor the way x...

sorting array after array_count_values

hi to all! I have an array of products $products = array_count_values($products); now I have an array where $key is product number and $value is how many times I have such a product in the array. I want to sort this new array that product with the least "duplicates" are on the first place, but what ever I use (rsort, krsort,..) i loo...

C and C++: Array element access pointer vs int

Is there a performance difference if you either do myarray[ i ] or store the adress of myarray[ i ] in a pointer? Edit: The pointers are all calculated during an unimportant step in my program where performance is no criteria. During the critical parts the pointers remain static and are not modified. Now the question is if these static ...

C++ pointer to different array

Assume I have an array a and an array b. Both have the same type and size but different values. Now I create 3 or so pointers that point to different elements in a, you could say a[ 0 ], a[ 4 ] and a[ 13 ]. Now if I overwrite a with b via a=b - Where will the pointers point? Do the pointers still point to their original positions in ...