arrays

VB.NET Array Initialization confuses me

Coming from a C# background, I have no idea why the following declarationr returns an array with length = 2, can someone please enlighten me? Dim lTestArray(1) As String Console.WriteLine(lTestArray.Length) (writes 2) ...

GCC: array type has incomplete element type ?!

GCC gives me an "array type has incomplete element type"-error message when i try to compile this: typedef struct _node node; struct _node{ int foo; node (*children)[2]; int bar; }; In memory the struct should look like this 0x345345000000 foo 0x345345000004 pointer to 1. child node 0x345345000008 pointer to 2. child node 0x345345...

Confusion in print method in Java

Whenever I try to print the char arrays to the console, I'm getting the result in integer format, but whenever I try to print integer arrays to the console, I'm getting the result in hashcode format. Could anyone please tell me why? char[] arr={'4','5','6'}; System.out.println(arr); //456 int[] arr={4,5,6}; System.out.println(arr) //[I...

Ruby consume array part by part

Hi, Let's say I've array with n elements. I want to take first ten elements and do something with them and then next ten and so on until array is done. What's the right Ruby way to do it? (With c-language background I could write some for-loop and inside the loop count to ten, do stuff and set my bookkeeping variable to zero and contin...

Java Array Indexing

class anEvent{ String number; String dueTime; } public static void main(String args[]) { int x = args.length / 2; int y = args.length; anEvent [] order = new anEvent [x]; for(int i=0; i<x; i++){ if(i==0){ order[i].number = args[0]; //Line(#) order[i].dueTime = args[1]; } ...

Check if $(this) has parents that have a class or id specified in an array

Hi again! First of all, after "testing" a while I have to say, stackoverflow is really really cool! To my question: I want to check if $(this) has not any parents that have a class or id specified in an js-array. By now I did this with "eval", but Andy E. just convinced me, that it is better to abandon "eval". However I have no clue h...

Why can one specify the size of an array in a function parameter?

I don't understand why the following example compiles and works: void printValues(int nums[3], int length) { for(int i = 0; i < length; i++) std::cout << nums[i] << " "; std::cout << '\n'; } It seems that the size of 3 is completely ignored but putting an invalid size results in a compile error. What is going on here?...

case-insensitive array_unique

I'm trying to write a few lines of code to make a case insensitive array unique type function. Here's what I have so far: foreach ($topics as $value) { $lvalue = strtolower($value); $uvalue = strtolower($value); if (in_array($value, $topics) == FALSE || in_array($lvalue, $topics) == FALSE || in_array($uvalue, $topics) == FA...

amfphp multidimensional array

Hi, in my Flex App, I have a 2-dimensional Array, something like this: arr[0][0] = "11"; arr[0][1] = "12"; arr[1][0] = "21"; arr[1][1] = "22"; I'm sending this array to my webservice: amfWebService.doSomethingWithThatArray(arr); I'm checking the result of the function (which is as string) with an Alert. Now to my problem: PHP so...

Convert numbers with toString in Ansi C

Is it possible to use toString operator, or how to convert numbers to char arrays. ...

How to manipulate an array similar to an ORDER BY clause in SQL?

My data has been placed into an array, but unfortunately not in the order I want it in... String[][] databaseToArray = { //{"Name", "Channel", "Description", "Amount", "isReady"}, {"John", "Nick", "likes", "2", "yes" }, {"Drew", "MTV", "dislikes", "4", "no" }, {"Fred", "CNN", "okay", ...

Create an array of countries and display them in a select box

Hello, I am new in Rails and I am trying to put countries in array and then display them in a select box. My array looks like this: country = {} country['FR'] = 'France' country['UK'] = 'United Kingdom' Any ideas? ...

php transforming a specific string into array values

hi, i get this response from the server: OK: 0; Sent queued message ID: e3674786a1c5f7a1 SMSGlobalMsgID:6162865783958235 OK: 0; Sent queued message ID: 9589936487b8d0a1 SMSGlobalMsgID:6141138716371692 and so on... This is just one long string with NO carriage return i copied it exactly as received. please note, initial OK can be a...

Get content from string in different situations

Hi, I'm thinking of storing data from a form as a string, each answer separated by a pipe. The problem I have is that some answers may come in the form of multiple items. We store the radio button selection along with their corresponding answers e.g. Question 1 - 1 Answer [A1] Question 2 - Radio button selected [A2] + 3 form fields Que...

Multidimensional JavaScript Array to PHP Array

I have been trying to figure this out for awhile. I have a multidimensional array in JavaScript that is 12 columns wide and an unknown number of rows like so /* [ [userID (int), name, username, email, password, other 1, other 2, other 3, other 4, other 5, other 6, admin(int)], [userID (int), name, username, email, password, othe...

Uninitialized string offset notice when using variable variables

When the run the following code, everything works fine until $i = 5. After that I get Uninitialized string offset notices, even though the arrays seem to be getting populated correctly. I get this notice when running locally but not when I check it on the remote server. Both are running v5.2.11. I assume the output is different from loca...

PHP how to get value from array if key is in a variable

Yes I know... I'm new.. anyways I have a key stored in a variable like so: $key = 4; I tried to get the relevant value like so: $value = $array[$key]; but it failed. Help. ...

PHP array multiple sort - by value then by key?

I have an array of string keys with numeric values for use in a list of tags with the number of occurances of each tag, thus: $arrTags['mango'] = 2; $arrTags['orange'] = 4; $arrTags['apple'] = 2; $arrTags['banana'] = 3; this is so i can display the tag list in descending occurance order thus: orange (4) banana (3) mango (2) apple (2) ...

Filter & Convert an Array into String using PHP

How can I turn this array: print_r($arr) Array ( [131] => stdClass Object ( [tid] => 131 [vid] => 9 [name] => apple [description] => [weight] => 0 ) [112] => stdClass Object ( [tid] => 112 [vid] => 9 [name] ...

Trying to create an array of DateTime objects -- Datetime[]

My brain doesn't seem to be working today. I googled around for this and just couldn't find it, which seems kind of strange since this is such a basic question that I can typically find out very quickly. I'm trying to create an array of DateTime objects. I can't use a List. DateTime[] dates dates[0] = Convert.ToDateTi...