arrays

Create another dimension to an array housing urls with base url.

Currently I have an array that lists email addresses as the key and urls as the values, I want to use parse_url (unless something better is suggested) and create another dimension to the array with the base url. This is what I currently have: array ( '[email protected]' => array ( 0 => 'http://www.google.co.uk/foo/bar', 1 => '...

how to iterate all array element starting from a random index.

I was wondering if is it possible to iterate trough all arrays elements starting from any of its elements without pre-sorting the array. just to be clearer suppose i have the array of 5 elements: 0 1 2 3 4 i want to read all elements starting from one of their index like: 2 3 4 0 1 or 4 0 1 2 3 the idea is to keep the element orde...

Assign Returned Pointer to Array

Hi, I have a function returning float* where it's actually filled as an array in the returning function such that float* some_fnc() { float *x=malloc(sizeof(float)*4); x[0]=...... } ... // in main float y[4]; y=some_fnc(); however I get an "Incompatible types" error, is it normal? Is there a way to overcome this w/o declaring...

Push call in Perl overwriting array

Ok, here's the deal. I have an array (inputted from a 400 MB file) where if I run the sort() command on it, comp runs out of memory. The input file isn't the problem, so I've decided to break the initial array into smaller arrays that I can perform the sort on. I can break the initial array into arrays of size 100k, which my code does...

For loop in NVelocity.

Does NVelocity support #for loops? I've looked through the documentation and all I could find was the #foreach loop. I want to loop over a 2 dimensional array. ...

Const space overflowed during CUDA build

Hi All, I have been running some CUDA examples and I wanted to make some edits to the code. There is a #define directive that sets the max array size in one of the .cuh files. When I try to make this larger than 2048 I get a compilation error: Temp/tmpxft_000010c8_00000000-11_MonteCarlo_SM13.compute_13.cpp3.i(0): Error: Const spa...

Compare arrays and remove duplicates, in Ruby?

What would be the easiest way to compare multiple arrays, and remove duplicates? So (arrays inside arrays in this case)... a = [[2, 1], [3, 3], [7, 2], [5, 6]] b = [[2, 1], [6, 7], [9, 9], [4, 3]] c = [[2, 1], [1, 1], [2, 2], [9, 9]] d = [[2, 1], [9, 9], [2, 2], [3, 1]] ...would come out (with priority given to array a, the...

php - get numeric index of associative array

I got an associative array and I need to find the numeric position of a key. I could loop through to find it but but is there a better way build into php? $a = array( 'blue' => 'nice', 'car' => 'fast', 'number' => 'none' ); // echo (find numeric index of $a['car']); // output: 1 ...

jquery get select options to array

Hi everyone, I'm kind of stuck with one - presumably simple to resolve problem. I want to create the code which will be used for all select elements on the site. Depending on the "label" attribute assigned to the "option" I want to hide all other "div" elements which have classes the same as other "label" values of the "options" in th...

Filter array by first letter

I'm building a platform. Somewhere in my code, there's an array that looks like this (PHP): $entries = array('p01','p02','g01','g02','a001','a002') I need to write a script that filters the array based on the first letter. For example, asking for those with the starting letter "p" would give me $filtered_entries = array('p01','p02');...

html form values to a javascript array

how to insert values in a html table, an array multidimensional in javascript. Additionally, such as performing calculations between the columns of the array and insert the results into a column of the same array. thanks for your answers. ...

Trying to sort a custom JavaScript object

Hi, I'm not too good at JS, but have survived thus far. I'm creating a sort-of complex JS object and wanting to sort it. The object's structure looks like this: cart.attributes = [ { Attribute, Value } ... ]; I'm creating a unique attribute that tells me 3 things separated arbitrarily by a colon: (Product ID):(Product...

Passing char array in a function?

Here is my problematic coding: I have to take in 2 player's name. Then when for the next part when the player marker changes the name stored in "currentPlayer" should change too the name stored in either playerOne or playerTwo. It doesn't so how do I fix that? Please solve, I tried to make it a reference variable with the & symbol but I...

multi-array search query with delimited field

I have a array which store some country names im doing a search module and i wanna to find the db records whether contain the country names or not but since db design problem , those record can own mutil counties and store the countries by delimiter "|" below is a example input: array("Cyprus","Austria") // note that the max input ...

Help Turning C++ coding into Function

SigTerm said this: "Smells like a bad code. squareOne..squareSix should be probably array. Instead of char constants, enums or ints should be probably used... " How do i do that with this code for the board also if someone could suggest the code I would have to use to get users to enter the row and column for the X and O for the game. v...

How does this "size of array" template function work?

Possible Duplicates: Can someone explain this template code that gives me the size of an array? Magic arguments in function templates Can someone explain how this code works? I know that the purpose of this code is to get the length of an array, but I don't know how this code works: template<typename T, int size> int GetArr...

Turn code into an Array and Display

How can I turn this into an array? I need a board to show blank spaces and when the user enters it gets filled with a X or an O by another function. The current board works I would like to make it into a array[3][3] and display the contents of the array. void showboard(char &squareOne, char &squareTwo, char &squareThree, char &squareFou...

Handling a variable number of arguments at runtime in a struct

Hello I have to classes, an Executer with these methods: Executer() struct Execute(string s) Lookup(string name, int module, int num, ...) and a Parser: Parser() struct Parse(string s) The Exectuers Execute method calls the Parsers Parse method. The Parser then chucks the string into smaller bits (it explodes the string on the ...

Interpreting linear memory space as 1D,2D,...,ND efficiently in C

Hi, Is it possible to allocate a 1D memory space int *x=(int *)malloc(100*sizeof(int)); and then recast the returned pointer to 2D array e.g. int **y=(int **)x; and access it as if it was 2D array e.g. y[1][2] = 12;? My aim is to take a shared memory segment and return 1D,2D,...ND array depending how the user wants to interpret this...

Whats the most efficient way of doing this?

Hey guys, I've got an array array of size N. For every 3 indexes in it I want to take them out and declare and assign those values to another array of size 3. I then want to go back to that array and take the next 3 and put it in a different array of size 3. I'll iterate like this for 3 different arrays of size 3 a1,a2,a3 once this is d...