arrays

How to access a $_POST item through the following array kind of syntax?

If i send four POST variables, but the second one I dont know that the name="" tag will be; how can I access it? Can i use $_POST[1] or not? ...

how do you concatenate to array items to create a new one and add it back into the same array (code Igniter)

Hi I have a query which returns a series of cells of data from a $this->db->query($sql) in the controller. What I want to do is foreach row of data, concatenate two of the cells and create a new cell then add it back to the array? For example, if i had an array: A 1 B 2 C 3 Then we can after processing the array A 1 A1 B 2 B2 C 3 C3...

PHP - Stepping through multi-dimensional array by key

I have a SOAP result set that the nuSoap extension has turned into a nice array for me. I'm sure I could scratch out some long way of looping it for what I want - but it seems there must be a faster way to just loop through the specific data elements. Here is the array: Array ( [xxxResult] => Array ( [NewDataSet] => Arra...

Circular Array C++

Hello, The code below is my own implementation a push_front method for my items array. I was wondering if someone could help me figure out how to implement the method so that i am just moving the indexes up or down. I need my items to stay in the array, rather then dumping them into a "front" varaible: stack::stack(int capacity) : item...

Filter Array of Values

I am using PHP and I have an array of user images that I need to filter. I need to do 2 different filters: Look in original array and see if each value contains a value in my "bad words" array Look and see if the value in the original array ends in one of "bad extensions" values Images Array: Array ( [0] => smiles.gif ...

postgres - comparing two arrays

postgres has an array data type, in this case a numeric array: CREATE TABLE sal_emp (name text, pay_by_quarter integer[]); INSERT INTO sal_emp VALUES ('one', '{1,2,3}'); INSERT INTO sal_emp VALUES ('two', '{4,5,6}'); INSERT INTO sal_emp VALUES ('three', '{2,4,6}'); SELECT * FROM sal_emp; Result: one, {1,2,3} two, {4,5,6} three, {2,4,6}...

mapping a postgres array with hibernate

has anyone successfully mapped a numeric array in postgres to a numeric array in java via hibernate? sql: CREATE TABLE sal_emp (name text, pay_by_quarter integer[]); INSERT INTO sal_emp VALUES ('one', '{1,2,3}'); INSERT INTO sal_emp VALUES ('two', '{4,5,6}'); INSERT INTO sal_emp VALUES ('three', '{2,4,6}'); mapping: <hibernate-ma...

array insertion (Bulk insertion) in oracle table with OCI.

Hi, Can anybody help me in a OCI program. I need to insert multiple row in a table (bulk insertion i.e. multiple rows at a time) with one column with clob data type. I am not getting any appropriate example for this. ...

Objective-C - How to compare arrays and extract the difference?

Possible duplicate: comparing-two-arrays I have two NSArray and I'd like to create a new Array with objects from the second array but not included in the first array. Example: NSMutableArray *firstArray = [NSMutableArray arrayWithObjects:@"Bill", @"Ben", @"Chris", @"Melissa", nil]; NSMutableArray *secondArray = [NSMutableArray ar...

Sorting blocks of L elements

I have an array of N * L integers int array[N * L]; I want to divide the array in N blocks of L elements and sort the blocks according to the classic list comparison (compare first element, than second, etc). In C I can do: qsort(array, N, sizeof(int) * L, comp); How can I achieve the same result using C++ std::sort(...) which is,...

c++: Initialize struct with one array containing all arguments

Hi, I am currently working on a small tokenizer template function which also casts the tokens to different objects. this works really nice aslong as all the strucs I cast to have the same number of items. what I would like to do know is to make the function cast to structs with any number of items. The bottleneck of the function for me ...

Removing Identical Objects in Ruby?

I am writing a Ruby app at the moment which is going to search twitter for various things. One of the problems I am going to face is shared results between searches in close proximity to each other time-wise. The results are returned in an array of objects each of which is a single tweet. I know of the Array.uniq method in ruby which ret...

PHP SimpleXml Elements to Array

Hello, I need to send a string of html has is like <total> <tag>content</tag> <tag2 ref="333"> <code>somecode</code> <code>morecode</code> </tag2> <tag3> more code </tag3> </total> This would go into an array like : $arra[] = "<tag>content</tag>"; $arra[] = "<tag2 ref="333">"; $arra[] = "<code ... etc But I'm not figuring out how to...

Why Object[].class.isAssignableFrom(String[].class) == true ?

Why is Object[].class.isAssignableFrom(String[].class) == true, while String[].getSuperClass() or getGenericInterfaces() could not get Object[]? I checked the source of JDK, but i don't think i can get the answer myself. For now, I know JDK uses tree to store the relationship between Classes, and depth to indicate its level, Class::isAs...

rotating multidimension matrix.

Given a 4x4 matrix, what formula could i apply to each (x,y) cell to yield an (x,y) if the matrix was rotated 90 degrees to the right? I tried iterating over each cell but different cells gave different formulas. Given the following matrix of values. 0| | | | | 1| | | | | 2| | | | | 3| | | | | ------------- ...

Python, creating triplets from array of words

Let's say I have an array or list of words, something like this: [The,Quick,Brown,Fox,Jumps,Over,The,Lazy,Dog] I'd like to generate an array of arrays, with each array containing 3 of the words, but with a possible triplet for each one. so it should look something like this: [The,Quick,Brown] [Quick,Brown,Fox] [Brown,Fox,Jumps] and...

reading in numbers using strings

I need to code a function that will take in x numbers. (x is read into the function as an argument) The numbers can be preceded and separated by any number of white spaces and new-lines, and after the last number is entered, a new-line character ends the scan. I thought about using strings the take in characters, and to disregard any non...

Python Array is read-only, can't append values

I am new to Python. The following code is causing an error when it attempts to append values to an array. What am I doing wrong? import re from array import array freq_pattern = re.compile("Frequency of Incident[\(\)A-Za-z\s]*\.*\s*([\.0-9]*)") col_pattern = re.compile("([-\.0-9]+)\s+([-\.0-9]+)\s+([-\.0-9]+)\s+([-\.0-9]+)\s+([-\.0-9...

Technique for determining if an integer sequence can be generated without branches?

If you're optimizing for an architecture on which branching is expensive (say the PS3's cell processor), it can be important to be able to determine whether or not you can express a given algorithm without using branches or at least using fewer branches. One pattern that I see a lot in unoptimized code is a bunch of if's used to tweak a...

Finding last pair in associative array

I'm looping through an associative array with a foreach. I'd like to be able to check if the key value pair being handled is the last so I can give it special treatment. Any ideas how I can do this the best way? foreach ($kvarr as $key => $value){ // I'd like to be able to check here if this key value pair is the last // so I can...