arrays

array of C++ string types

These are my variables: const int sizeOfLicToCheckFor = 3; string licNameToCheckFor[ sizeOfLicToCheckFor ] = { "PROF", "PERS", "PREM" }; when I run my program licNameToCheckFor is only initialized with "PROF" and nothing else. What am I doing wrong? ...

Sum integers in 2d array using recursion ?

Hello! I need some help with this problem. I have to sum alle the integers in a 2d array using recursion. Below is what I have managed to do on my own, but I'm stuck. This code generates the sum 14, which should be 18. Any suggestions? Is the base case wrong? Or is the recursive method wrong? public class tablerecursion { public static...

jQuery getting value of array by index

Hello, using jQuery, I'm trying to get values of fileTypes by using an index. I'm not sure how to do go about doing this but so far I've tried settings.fileTypes[0] which does not work. Any help is appreciated, thanks! var defaults = { fileTypes : { windows: 'Setup_File.exe', mac: 'Setup_File.dmg', ...

php array push - associative arrays and keep associative keys

I have several associative arrays, each starting with a string key. I also have a master array that i want to use to combine each of these sub arrays. When using array_push though, each array is then given an additional numeric key in the master array. How can i avoid this and push the sub arrays into the master array keeping the keys...

Where do I define my const array in C?

I'm writing some C and I have a lookup table of ints. I'm a little rusty... where do I declare and initialize the array so that I can use it in multiple C files? Can I declare it in an H file and initialize it in a C file? ...

Taking N number of arrays and turning it into a multidimensional array with N rows JAVA

I am trying to write code that will turn N arrays into a multidimensional array with N rows. I currently have a code that can turn 2 arrays into a multidimensional array with 2 rows. However, I am unsure how to modify it in order to make this code take N arrays. Additionally my code currently can only take arrays of the same size. Howev...

Create array without declaring it first - Ruby

Howdy! I'm sorry if this question is a dumb one, but I must ask. In PHP, we can create a array without declaring it first, althought it isn't considered good pratice. Exercising my newly-knowledge of Ruby, I was writing a code to list the files inside a directory and sort them by their extensions. To do this, I started a loop to put the...

How can you sort an array of GPS coordinates to draw a non-overlapping bounding box?

I have a collection of GPS coordinates (Lat/log) in an array that I want to use to create a polygon in google maps. If i use the unsorted array, the polygon lines are drawn in the order of the array index. I am wondering if there is a way to sort the array such that when i draw the polygon, the borders do not overlap. Any insight will ...

defining an array key and value within a foreach statement

I have a mysql statement which returns 2 values for each row. Each time I loop through these results, i want to add them to an array. I want one value to be the key, and the other to be the array value. I tried this, but it doesn't seem to work: $dataarray[] = $row['id']=>$row['data']; ...

Very large array on the heap (Visual C++)

Hello, I hope some one can help me, i'm trying to create an int[400000000] (400 millions) array on my application using visual c++ 2010 but it generates an overflow error The same code runs on linux with g++. I need this because i'm working with large matrices. Thank you in advance. ...

most effecient way to order an array by sub elements?

I have a multidimensional array. $array[0] = array(1, 8, 2); $array[1] = array(5, 6, 15); $array[2] = array(-8, 2, 1025); I am wondering what the most efficient way to order the parent array by a particular property of it's sub array. For example, I want to put them in ascending order of $sub_array[1], so the parent array would be...

How can I remove ALL duplicates from an array in PHP?

First of all, I'd like to point out to all you duplicate question hunters that this question does not fully answer my question. Now, I've got an array. We'll say that the array is array(1, 2, 2, 3, 4, 3, 2) I need to remove the duplicates. Not just one of the duplicates, but all, so that the result will be array(1, 4) I looked at arra...

JQuery dropdown list values to php array?

How can I pass all the values from one dropdown list to one PHP array? Let's say that I have one dropdownlist name="country" and id="countries" Options: val="Japan" Japan val="USA" USA val="UK" UK How can I parse the values to one PHP array? The content is generated dynamically from another dropdownlist by chained method. Cheers! ...

Check if the next array element is different from the current in Java

I would like to tell if the next line is different from the current line or this is the last line. Is that sure that I won't get an ArrayIndexOutOfBoundsException if I use this code? And is it a good way to check this? for (current_line = 0; current_line < lines_array.length; current_line++) { /* ... */ boolean nextLineIsDiffere...

how can i get the value of array

Hi, i want to get all the values on "ListNumber", how can i loop it using php? thanks in advance :) [ListNumbersList] => SimpleXMLElement Object ( [Record] => SimpleXMLElement Object ( [Returned] => 1 ) [ListNumber] => Array ( [0] => 1 ...

Finding the median value of an array?

Hello, I was wondering if it was possible to find the median value of an array? For example, suppose I have an array of size nine. Would it possible to find the middle slot of this array? ...

How can I add an array to an array of arrays using jQuery?

I have an array, as below: var cString = [ ['1','Techdirt','www.techdirt.com'], ['2','Slashdot','slashdot.org'], ['3','Wired','wired.com'] ]; to this array I want to add another in the same format: var test = ['4','Stackoverflow','stackoverflow.com'] I've tried using: var newArray ...

PHP arrays setting to false

How do I make it so every array is set to false .. I don't want to do it like this: $a = array('clue1' => 'false', 'clue2' => 'false', 'clue3' => 'false'); because that will take long time. Is there easier way? ...

Have Arrays in .NET lost their significance?

For every situation that warrants the use of an array ... there is an awesome collection with benefits. Is there any specific use case for Arrays any more in .NET? ...

Concatenate the elements in a PHP array

How can I turn the following array below so it looks like example 2 using PHP. Example 1 array. Array ( [0] => &sub1=a1 [1] => &sub2=aa [2] => &sub3=glass-and-mosaics [3] => &sub4=guides-and-reviews [4] => &sub5=silent-movies [5] => &sub6=even-more-eastern-religions-and-philosophies ) Example 2. &sub1=a1&sub2=aa&sub3=glass-and-mosa...