multidimensional-array

problems with putStringArrayListExtra() in Android

Hi I want to pass an Arraylist from one activity to another. I use putStringArrayListExtra(), but there shows an error : "The method putStringArrayListExtra(String,ArrayList is undefined for the type bundle." Is there any other method available for passing ArrayList? String test[]=new String[3]; ArrayList<String[]> al=new ArrayList...

Passing multidimensional array using Serializable

Hi, I have passed one multi-dimensional array to another activity using putSerializable() and retrieve using getSerializable. But I got some problems. Please help me to solve my problem.. First activity String [][] selected_list= new String[10][]; Bundle list_bundle=new Bundle(); list_bundle.putSerializable("lists",se...

Javascript: Building an array with a variable

Is it possible to take the contents of a variable and stick it into an array like so (I've tried to no avail): First I get these values from a database and using php form into a hidden input: {value: '1', name: 'name1'},{value: '2', name: 'name2'} Then collect with javascript document.getElementById("myelement").value Then put the...

How can I sort a multidimensional array using php?

Hi I have to sort this array in desc. order on the basis of ratingVal using php. How can I do that. Array ( [0] => Array ( [rating_postid] => 26 [raCnt] => 6 [sRate] => 18 [ratingVal] => 3 ) [1] => Array ( [rating_postid] => 714 [raC...

assigning value to a 2-Dimensional array

How can I assign value to a 2-dimensional array? My array is String[][] arr=new String[2][3]; And when I am assigning value to this array, application is stopped. Example: arr[0][0]="hello"; Please give me the solution... ...

sortting multi-dimensional arrays

I would like to be able to sort this array by the element array's size; array( [0] => array( [0] => 'B', [1] => 'C'); [1] => array( [0] => 'B'); [2] => array( [0] => 'A', [1] => 'C'); [3] => array( [0] => 'A', [1] => 'B', [2] => 'C'); [4] => array( [0] => 'C'); [5] => array( [0] => 'A'); [6]...

How can I use __call to dynamically return property values

Hello, I've been trying to think of a way to dynamically return property values for a class using __call instead of creating a slew of functions whose only purpose would be to return those values. The idea I have is to be able to request ( for example ) $this->fetch_PersonFirstName() and have the class check if $this->person["first_name"...

PHP preg_match_all CamelCase, obtaining prefix_ and CamelCased elements

Hello, I'm trying to use preg_match_all to return an separate arrays for various elements in a CamelCase string. In my example, I'm attempting to obtain the prefix of a string in one array and everything else ( the camelcase portion of the string ) split up into a second array. For instance, get_BookGenreTitle is supposed to return get_ ...

Storing values in PHP

I am trying to store values in php, like a HashTable with multiple keys. For example I am I would want this to return two different values: $value1=$content['var1']['var2']['var3']['typea']; $value2=$content['var1']['var2']['var3']['typeb']; What would be the best way to go about implementing a feature like this? ...

How do I get sum of value based on same key until some point in an array?

I have an array as following. I order that array by the value of the key "attack". Everything is ok until then, but I want to get for example only 9 of that total attack values are summed up: I want to sum up 3 of key1 (3 * 45), 4 of key3 (4 * 35) and 2 of key2 (2* 25) are automatically summed up. I would be greatly appreciated if somebo...

How can I select like this using mysql query?

Hi I have two different tables containing lot of images. I need to display 50 random images from both tables. How can I do like that. How can I select random images using MySQL? or if I select 100 images from both tables. How can I choose 50 random images from that array using php? any body knows the solution please help me. ...

php shift in a hierarchy array

Hello. I have the next array: Array( [id] => 1 [children] => Array( [2] => Array( [id] => 2 [inactive] => true [children] => Array( [4] => Array( [id] => 4 [children] => Array() ) ) ) [3] => array( [id] => 3 ...

Boost.MultiArray Beginner: How to get a 4D-Array with dynamic inner-array-sizes?

Hello, i want to store some kind of distance-matrix (2D), where each entry has some alternatives (different coordinates). So i want to access the distance for example x=1 with x_alt=3 and y=3 with y_alt=1, looking in a 4-dim multi-array with array[1][3][3][1]. The important thing to notice is the following: the 2 most inner arrays/vect...

At least two errors: (syntax) CS0103 and (crashing program) for Loop

I am having two major problems with the source code below (and probably other problems I haven't yet discovered...). Problem Number 1: I have to apply the declared integer fields (day, month, year) under the class Friend to a string array in my Main() method. The way that I wrote the source code below doesn't allow for a definition for...

Can PostgreSQL index array columns?

I can't find a definite answer to this question in the documentation. If a column is an array type, will all the entered values be individually indexed? I created a simple table with 1 int[] column, and put a unique index on it. What I noticed is that I couldn't add the same array of ints, which leads me to believe the index is a compos...

populating table using 2D array (java)

Hi, I'm doing my first steps with 2D arrays. Help needed on a practical example. Below code should store students and each of their results for 3 courses in a table. Below code returns an error. The error is caused by int studentResults[x][y] = sc.nextInt(); . Any ideas? import java.util.*; class CalcAverage { public static void ...

Max number of dimensions in a Java array

Out of curiosity, how many dimensions of an array can you have in java. ...

Algorithm for 2D grid problem?

Hello everyone, I will be honest, this is an assignment question but I just cant find a solution to it. Please remember I am not asking for the answer but simply some guidance. Problem: Design an algorithm that runs in O(n) time (linear) which can locate a single suspicious house (point) on a 2D grid. It is suspicious if it consumes eq...