arrays

Taking 2 dimensional array and outputting 1 dimensional array in JAVA

I am trying to take a two-dimensional array and run it through a series of calculations in order to transform it into a one-dimensional array. However, when I run my program I keep getting this long error Exception in thread "main" java.lang.Error: Unresolved compilation problems: Duplicate local variable raw_advisor Syntax er...

Int and Double in one array in Java

Is there a way to put an int and a Double in the same array. I want to have an array (p1[]) where the first (p1[0]) is an int and all the rest of the elements are doubles. Is this possible? ...

C# - Appending strings to a string array

How can I append strings to an array if a certain checkbox is true? //Create an array to hold the values. string[] charArray; if (abc.Checked == true) { //append lowercase abc } if (a_b_c.Checked == true) { //append uppercase abc } if (numbers.Checked == true) { //append numbers } if (symbols.Checked == true) { //app...

C Parameter Array Declarators

In C99 there are variable-length arrays, and there can be static qualifiers (and type qualifiers) in parameter array declarators: void f(int i, int *a); void f(int i, int a[]); void f(int i, int a[i]); void f(int i, int a[*]); // Only allowed in function prototypes. void f(int i, int a[static i]); Since array function paramete...

Hashtables not really working.

Hi! I'm doing some web development, and I'd like to use an associative array in my code. I've used hashtables in other design work, and they definitely do the trick. However, when I try to call "var coms = new Hashtable();", I get errors stating that there is no class hashtables. I've read that in JS all objects ARE hashtables, so I su...

php move nodes to parent array

How could I move all nodes of the 'fields' array into its parent array '113', whilst unsetting 'fields' ? [a] => Array ( [113] => Array ( [title] => asdfasdfas [alias] => asdfasdfas [fields] => Array ( [jr_streetaddres...

Declaring a huge dynamic array with tiny cells [C++]

Hello, I have this project I'm working on. The following conditions apply In this project I need to create one huge array (hopefully I will be able to create one as big as ~7.13e+17, but this target is still up ahead.) Each cell inside the array can contain one of the three values: 0,1,2 I'm using C++ as my language. I tried using th...

Search in array query result in php/mysql

I have the mysql results ($date_options) as below Array ( [0] => stdClass Object ( [id] => 4 [start_date] => 2010-09-29 ) [1] => stdClass Object ( [id] => 13 [start_date] => 2010-10-06 ) ) I need to be able to search in the "id" field if some value existed. I tried this and it didn't wor...

splitting string by C#

I've got this string: UNB+UNOA:1+094200005560743089001003:OD+094200005565200077SP0001:OD+100705:1017+570180'UNH+1+SYNCRO:2::OD'MID+102711015461800+100705:1014'CDT+::::::BQ6UB'BDT+::::::1003-002'CSG+:Nisses MONTERING:::::BP2TH+005+TCSB'SEQ+CR+2059433+YV1CM5957B1574778:602816985'ARD+39855213::PART NO'SDD+100705+1'UNT+9+1'UNZ+1+5701...

PHP explode array

I'm trying to get random values out of an array and then break them down further, here's the initial code: $in = array('foo_1|bar_1', 'foo_2|bar_2','foo_3|bar_3','foo_4|bar_4','foo_5|bar_5' ); $rand = array_rand($in, 3); $in[$rand[0]]; //foo_1|bar_1 $in[$rand[1]]; //foo_3|bar_3 $in[$rand[2]]; //foo_5|bar_5 What I want is same as abov...

JAVA, array taking a variable number of objects as parameters

I am trying to get an array to take a variable number of objects as input. I am new to programming so I apologize in advance. Here is my code: public class Rating{ double [] Ratings; int CustomerID; int Domain; public Rating (int id, int d, double [] x) { double [] Ratings = x; int CustomerID=id; ...

php create array out of string one per line

i got a $str ="sometxt<br>another<br>moretext<br>evenmoretext<br>"; i'm trying to output the string in one array per line. kinda like this.. [0] => Array (['stuff'] => sometext ) [1] => Array (['stuff'] => another ) [2] => Array (['stuff'] => moretext ) [3] => Array (['stuff']...

PHP array values to associative array keys?

Is there a quick/easy PHP function to take the VALUES of an array and create an new associative array from the value mappings? or is this a classic iterate, parse, and add? Example, source array in var_dump() form: array(3) { [0]=> string(36) "md5=397f7a7501dfe5f18c1057885d698d5d" [1]=> string(7) "foo=bar" [2]=> string(7...

How to echo out all elements of php array at once ?

hi friends I have a php array for eg. $mob_numbers= array(12345674, 12345675, 12345676,12345677); I want to eacho out all of them at once so that it appears 12345674,12345675,12345676,12345677 (with comma) . How do i do it ? I tried array explode, didn't work. Pls help ...

php sort array issue

i want to sort an array by alphabet when i use asort() its sorting , but the results that i get is first of all , the names in upper-case, and after that all the names with lower-case like : Avi Beni .. .. avi beni if i want like : Avi avi Beni beni .. .. how can i do it ? ...

Javascript pass array attribute as parameter

var contact = { varWorkExperiences: [{ Experience: "aaa" },Experience: "bbb"}] }; I have a structure like this. I can use push method like this: contact.varWorkExperiences.push({ Experience: "ccc"}); but I want to do this paramaticly I cant do this: var x = "Experience"; contact.varWorkExperiences.push({ x: "ccc"}); How can I ...

How to find the next numeric index of an existing array?

I'm looking for a simple way to obtain the next numerical index of an array for a new element that would have been chosen by PHP as well. Example 1: $array = array(); $array[] = 'new index'; This would be 0 for this case. Example 1a: $array = array(100 => 'prefill 1'); unset($x[100]); $x[] = 'new index'; This would be 101 for thi...

What is the fastest portable way to copy an array in C++

This question has been bothering me for some time. The possibilities I am considering are memcpy std::copy cblas_dcopy Does anyone have any clue on what the pros and cons are with these three? Other suggestions are also welcome. ...

php tree class/array structure to breadcrumbs

Basically i received an API SOAP response of a list of categories in an class format as in array kind of way with CatID, name, parentID, level. What is the best way to turn this into an array of breadcrumbs for each CatID. I want to try reduce the number of operation as the array will be created on the fly to populate a drop down me...

standard / readable array declaration and using

what in your opinion more standard / readable / efficient code of array declaration : one way : $days = array(1=>'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); then use : $days[$value] or the second way : $days = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); then use : $days[$value-1] update : i cant sure that the...