arrays

Please help with passing multidimensional arrays

Hi, I'm writing a simple test program to pass multidimensional arrays. I've been struggling to get the signature of the callee function. The code I have: void p(int (*s)[100], int n) { ... } ... { int s1[10][100], s2[10][1000]; p(s1, 100); } This code appears to work, but is not what I intended. I want the function p to be obl...

How to get JSON objects value if it's name contains dots?

I have a very simple JSON array (please focus on "points.bean.pointsBase" object): var mydata = {"list": [ {"points.bean.pointsBase": [ {"time": 2000, "caption":"caption text", duration: 5000}, {"time": 6000, "caption":"caption text", duration: 3000} ] } ] }; // Usually we ...

php string in to array (key and val must be same string)

Hi , Using explode i have converted the string into array , But the array look like Array ( [0] => root) But i want i make my array somthing like Array ( [root] => root) How to make this manner.. Thanks ...

Number of elements in static array and dynamic array

What is the quickest way to find the number of elements in a static array and dynamic array? ...

Comparing One Value To A Whole Array? (C#)

Let's say I have a C# variable and array: int variable_1 = 1; int[3] array_1 = {1,2,3}; How can I check if the value of variable_1 is equal to any of the values in array_1 without looping through array_1? ...

[Perl] Retrieve the reference

Hello, with the hash below, I would like the clients array's reference : my $this = { 'name' => $name, 'max_clients' => $max_clients, 'clients' => () }; I can't do "\$this{'clients'};" to retrieve the reference. ...

Javascript Accessing Multidimensional Array Keys

Hi guys. I have a javascript array that looks like this: '40x27' => array( '1' => 0 '1.5' => 2 '2' = 1 ) '36x24' => array( '1' => 1 '1.5' => 1 '2' = 2 ) etc. I want to print out the values of the inner array like this: i = 0; for (i in outerArray){ var k = 0; for (k in innerArray){ ...

In Ruby how do you sort one multi dimendional array by another multi dimensional array?

Lets say I have an array : a=[[1,2,3],[4,5]] and I have another array : b=[[2.5,1.5,3.5],[1.5,2.5]] I need to sort 'a' with respect to 'b'. i.e the output should be = [[3,1,2],[5,4]] I tried but my code seemed to be very lengthy. It would be great if you could help me out.Thanks! ...

Duplicating an array of strings.

arr = ["red","green","yellow"] arr2 = arr.clone arr2[0].replace("blue") puts arr.inspect puts arr2.inspect produces: ["blue", "green", "yellow"] ["blue", "green", "yellow"] Is there anyway to do a deep copy of an array of strings, other than using Marshal as i understand that is a hack. I could do: arr2 = [] arr.each do |e| ar...

C: External const ints in a array of const struct

I am getting an error message "expression must have constant value" when initializing an array of structures with an external constant integer. File1.c: const unsigned char data1[] = { 0x65, 0xF0, 0xA8, 0x5F, 0x5F, 0x5F, 0x5F, 0x31, 0x32, 0x2E, 0x31, 0xF1, 0x63, 0x4D, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x44, 0x20,...

Sorting an array into a multidimensional array based on "parent_id"

I'm storing an infinitely nested directory structure in mysql by assigning a "parent_album_id" to each "album" (unless it's at the top level, in which case it does not have a parent_album_id). I first grab an array of all the albums from the database and change each albums key to it's "id" (autoincrement id). Next, I want to reorganize...

parsing numbers in a javascript array

Hi I have a string of numbers separated by commas, "100,200,300,400,500" that I'm splitting into an array using the javascript split function: var data = []; data = dataString.split(","); I'm trying to parse the values of the array using parseFloat and then store them back into the array. I'd then like to add up the numbers in the ar...

[Oracle/PHP]Is it possible to pass an array to a PL/SQL procedure?

If it is possible, how does the parameter need to look like in the procedure? And how do you pass an array to a procedure? ...

most efficient method of turning multiple 1D arrays into columns of a 2D array

As I was writing a for loop earlier today, I thought that there must be a neater way of doing this... so I figured I'd ask. I looked briefly for a duplicate question but didn't see anything obvious. The Problem: Given N arrays of length M, turn them into a M-row by N-column 2D array Example: $id = [1,5,2,8,6] $name = [a,b,c,d,e] $r...

Building an array out of values from another array

This is a follow up from a question of mine that was just answered concerning parsing numbers in an array. I have an array, data[], with numbers that I'd like to use in a calculation and then put the resulting values into another array. So say data[0] = 100. I'd like to find a percentage using the calculatin, (data[0]/dataSum*100).toF...

routine to generate a 2d array from two 1d arrays and a function

I'm guessing that there's a word for this concept, and that it's available in at least some popular languages, but my perfunctory search was fruitless. A pseudocode example of what I'd like to do: function foo(a, b) { return a * b // EG } a = [ 1, 2, 3 ] b = [ 4, 5, 6 ] matrix = the_function_for_which_I_search(foo, [a, b] ) print m...

[PHP]: What does array_search() return if nothing was found?

What does array_search() return if nothing was found? I have the need for the following logic: $found = array_search($needle, $haystack); if($found){ //do stuff } else { //do different stuff } ...

Convert image into useable byte array in C?

Does anyone know how to open an image, specifically a jpg, to a byte array in C or C++? Any form of help is appreciated. Thanks! ...

How can I make a resizable array in Java?

What is the best way to do a resizable array in Java? I tried using Vector, but that shifts all elements over by when when you do an insert, and I need an array that can grow but the elements stay in place. I'm sure there's a simple answer for this, but I still not quite sure. ...

Can I put some form of If..End blocks inside of a hash definition?

I am creating a web application to integrate with Chargify. I want to return a hash with customer_id set if the user has a customer associated with the account, and customer_attributes if a customer has to be created. Is there any way that I could do this with an if..end block inside of the hash definition. For example, I would be wanti...