arrays

Asp.Net DataList bind array of *.aspx ImageUrls

The code below works perfect for binding actual urls grabbed from the net. My issue is that it does not work for *.aspx urls that generate an image. If I go to the *.aspx page "~/UserPages/Photo/GetThumbnail.aspx?id=7", an image shows up just fine. However it does not work for the datalist. Any ideas why and how I can solve this issue. T...

Parsing multiple XML feeds with PHP into one sorted array

I want to create a sortable list that looks something like $VAR1[0], $VAR2[0]... $VAR1[1], $VAR2[1]... The data comes from multiple same structured xml files: $xmlfile=" <Level1> <Level2> <Level2Item VAR1="1" VAR2="2" ... /> <Level2Item VAR1="4" VAR2="5" ... /> <Level2Item VAR1="7" VAR2="8" ... /> </Level2> </Level1>"; //Ex...

Implementing a matrix, which is more efficient - using an Array of Arrays (2D) or a 1D array?

Hey everyone, When implementing a Matrix construct using arrays, which would be more efficient? Using a 1D array, or an array of arrays (2D)? I would think a 2D is more efficient as you already have the X and Y coordinates of an element, where in a 1D implementation you have to calculate the index. Any thoughts? Thank you Edit: it ...

How to copy part of an array to another array in C#

How can i copy a part of an array to another array. Consider i'm having, int[] a = {1,2,3,4,5}; now if i give the start index and end index of the array 'a' it should get copied to another array. Like if i give start index as 1 and end index as 3, the elements 2,3,4 should get copied in new array.! ...

PHP: Strange Array Problem - Where is my value?

I have an array ($form) which retreives some information from $_POST: $form = $_POST['game']; Now I want to work with the values in this array, but I somehow fail. For debugging I used these commands (in the exact same order, with no extra lines inbetween): print_r($form); echo '#' . $form['System_ID'] . "#"; and as returned outpu...

Processing a string in PHP

Hi, I need a way of sorting a string I have in PHP, the string is formatted like the one below, but is much bigger. { 1, 3, 1, 2, }, { 2, 3, 2, 1, }, { 3, 3, 2, 2, }, { 1, 2, 3, 1, }, What I would need it to do is turn each set of numbers that is in the brackets into an array. So in this case there would be four arrays with four value...

Dynamically build an array for web service C#

I'm using C# and asp.net to query a web service. The user will enter the number of guests and then I need to add that number of guests to the web service call. Creating the guests manually like this works. // Create room layout for searching Guest adult = new Guest(); adult.Id = 1; adult.Title = "Mr"; ...

Make array value variable (PHP)

Hi, Say I want to echo an array but I want to make the value in the array I echo variable, how would I do this? Below is kind of an explanation of what I won't to do but it isn't the correct syntax. $number = 0; echo myArray[$number]; ...

How do I find the smallest item in an array?

I have an array, and need to find the index of the smallest item. a = [2, 2, 2, 3, 3, 4, 3] This should return 0. Please note that the content and ordering of the array must not be modified. I am looking for a solution in either C or Java. ...

Postgres - How to check for an empty array

I'm using Postgres and I'm trying to write a query like this: select count(*) from table where datasets = ARRAY[] i.e. I want to know how many rows have an empty array for a certain column, but postgres doesn't like that: select count(*) from super_eds where datasets = ARRAY[]; ERROR: syntax error at or near "]" LINE 1: select count...

How can I convert a function return value from reference to array?

I have this code in Perl: sub f { return [1,2,3] } print f; The function f returns reference to array, how can I convert returned value to array without additional variable, like here? sub f { return [1,2,3] } $a = f; print @$a; ...

Filter array - odd even

How can a filter out the array entries with an odd or even index number? Array ( [0] => string1 [1] => string2 [2] => string3 [3] => string4 ) Like, i want it remove the [0] and [2] entries from the array. Or say i have 0,1,2,3,4,5,6,7,8,9 - i would need to remove 0,2,4,6,8. ...

How to efficiently get short array from resources on Android?

I've got an XML file storing an array of shorts in my resources. I need to assign this array, but Android API only provides a way to get array of ints (getResources.getIntArray()). I've ended up getting an array of ints and converting it to array of shorts later, but that's hardly ideal. Is there a way to get an array of shorts from And...

How do I output each Perl array element surrounded in quotes?

I want to output the elements of an array in a specific format in Perl. @myArray = ("A", "B", "C"); $text = something; Something should be the string '"A" "B" "C"' (each element enclosed in double quotes). However, if @myArray is empty, then $text should be too. I thought of using join(), such as $text = "\"" . join("\" \"", @myArra...

Ruby arrays - cannot access value

Hey, So I am doing a small, simple project for my class and for some reason I can't access a value using a variable. This is my class: (I am having problems with the getAnswer method, in particular the answerArray array) #Create random fact array class RandomFact def initialize() @randomNum = rand(5) end def getQuesti...

Converting an array of keys and an array of values into a hash in Ruby

I have two arrays like this: keys = ['a', 'b', 'c'] values = [1, 2, 3] Is there a simple way in Ruby to convert those arrays into the following hash? { 'a' => 1, 'b' => 2, 'c' => 3 } Here is my way of doing it, but I feel like there should be a built-in method to easily do this. def arrays2hash(keys, values) hash = {} 0.upto(k...

Using arrays and pointers in C# with C DLL

I am very new to C# (just started learning in the past week). I have a custom DLL written in C with the following function: DLLIMPORT void test_function (double **test) What I am looking to do is have a pointer from C# for the array 'test'. So, if in the DLL function I have test[0] = 450.60, test[1] = 512.99 etc. I want to be able t...

PHP syntax for dereferencing function result

In every other programming language I use on a regular basis, it is simple to operate on the return value of a function without declaring a new variable to hold the function result. In PHP, however, this does not appear to be so simple: <?php function foobar(){ return preg_split('/\s+/', 'zero one two three four five'); } // can ...

What's wrong with my PHP array?

$genreList; function directorGen($array) { foreach($array as $value) { $genreList[] = $value; } } //later.. directorGen($title->genres()); This code results in a NULL array. If I replace $genreList[] = $value with echo $value everything prints out like expected. Any ideas? ...

Passing an Array as Arguments, not an Array, in PHP

I seem to remember that in PHP there is a way to pass an array as a list of arguments for a function, dereferencing the array into the standard func($arg1, $arg2) manner. But now I'm lost on how to do it. I recall the manner of passing by reference, how to "glob" incoming parameters ... but not how to de-list the array into a list of a...