arrays

Creating readable list output in PHP/Wordpress

I'm trying to figure out how best to get this PHP statement $wpdb->get_results("SELECT verb, display_name AS organization, inline_the FROM userorganizations U, organizations O WHERE U.org_id = O.ID AND U.user_id=$author_id", OBJECT); To spit out something like the following: John works for Initech, owns John's Tasty Pastry, and w...

C++ scanf/printf of array

I've written following code: int main() { double A[2]; printf("Enter coordinates of the point (x,y):\n"); scanf("%d,%d", &A[0], &A[1]); printf("Coordinates of the point: %d, %d", A[0], A[1]); return 0; } It's acting like this: Enter coordinates of the point (x,y): 3,5 Coordinates of the point: 3, 267...

Search and match from array

Search an array - I found this function below to search an array which is "great" for single strings, it will match an array value and or array value and matching key within an array, BUT what i really want to do is ONLY match an array where ALL the search values are met/returned. the query example could return matches for any records wh...

Undefined index when assigning value to array element

In while loop I'm assigning value pulled from DB to the array like so: $states[$row['state']] PHP gives me the following notice: Notice: Undefined index: ME in /var/www/vhosts/basementfinishing-md-de.com/httpdocs/inc/class.cityBlock.php on line 67 What I'm doing wrong here? ...

how combine multiple arrays into a single associate array using the arrays as keys

I have 2 arrays that i would like to loop through and combine into an associative array. I would like to use the 2 arrays as the keys for the new associative array. I am new to php so any and all help would be appreciated. $id = array( 2, 4); $qty = array( 5, 7); array('id' => , 'qty' => ); Thanks in advance I would like to output...

Sorting an array, from high to low.

I have an array containing multiple integers, is there a common way for sorting it from high to low? ...

Remove Null elements from a (String) Array in Java

Hey guys, I'm new to Java (well, 3/4 of a year spent on it). So I don't know much about it, I can do basic things, but the advanced concepts have not been explained to me, and there is so much to learn! So please go a little but easy on me... Ok, so I have this project where I need to read lines of text from a file into an array but on...

Sorting two corresponding arrays

I have this code here that has two arrays. It sorts arr[], so that the highest value will be in index 0. Now the second array arr1[] contains strings, I'd like the code to apply whatever changes where made to arr[] to arr1[]. So that arr[0] would return 6, while arr1[0] would return the string "d1". Notice how "d1" was at the same index...

How do I find a particular value in an array and return it's index?

Pseudo Code: int arr[ 5 ] = { 4, 1, 3, 2, 6 }, x; x = find(3).arr ; x would then return 2. ...

Multi-Attribute Sorting and Filtering on an Array of Structs

I have an array of structs. Each struct has the following two attributes: win % # of wins I want to sort the array of structs by win %; however, for only those structs with at least 3 wins. Any suggestions? ...

Rails - Iterating through nested arrays

Hi I'm very new to rails and need some help on iterating through nested arrays. I'm trying to figure out how to do mass-inserts for each values that is different between the make, model and color of cars. The params that are pass are: "make" => ["Honda", "Honda"], "model" => ["Civic", "Accord"], "color" => [{"Black", "White", "Red"}, {...

adding textual column and row headers to numpy array

I am creating a 2d summary matrix from a 3d array using the following code: numTests=len(TestIDs) numColumns=11 numRows=6 SummaryMeansArray = p.array([]) summary3dArray = ma.zeros((numTests,numColumns,numRows)) j=0 for j in range(0,len(TestIDs)): print 'j is: ',j TestID=str(TestIDs[j]) print 'TestID is: ',TestID read...

jQuery - array with dynamic field names

I am passing this function different field names on each call. I would like it to post the interpolated string value of the variable field as the name of the posted var. Eg one post might have data: { 'shoppingCartContents' : cartrow, 'number' : number, 'foo' : value } but every post just has data: { 'shoppingCartContents' : cart...

Why does Arrays.toString(values).trim() produce [bracketed text]?

Map<String, String[]> map = request.getParameterMap(); for (Entry<String, String[]> entry : map.entrySet()) { String name = entry.getKey(); String[] values = entry.getValue(); String valuesStr = Arrays.toString(values).trim(); LOGGER.warn(valuesStr); I'm trying to look at a request parameter value using the code above. ...

from datatable to array، no loop

Following Code for transmission to the list box is : DataTable dt = new DataTable(); DataColumn dc = new DataColumn("BestSite", typeof(string)); dt.Columns.Add(dc); for (int i = 1; i <= 10; i++) { DataRow dr = dt.NewRow(); dr[0] = i.ToString() + " = stackoverflow"; ...

Problem with decoding JSON as array or object with PHP

I'm trying to use PHP to process JSON and am having trouble parsing it as either an object or a string. Here is the JSON feed: stdClass Object ( [Response] => stdClass Object ( [Meta] => stdClass Object ( [ExecutionTime] => 0.41602396965 ) [Data] => stdClass Object ( [Entity] => stdClass Object ( [id] => 1 [name] => Wal-Mart Stores [de...

How do i store a set of values in an array without using square brackets, but by using pointers

In C programming, how can a store a set of values entered by the user into an array using only pointers and no square brackets? ...

Predict the number

I want the user to enter a 4 digit number and the program must tell what that 4 digit number was i.e generate that 4 digit number by Brute force attack.But at the line mentioned below the compiler says invalid indirection.I would also like to have some comments about they way I am implementing it,is it a good practise? #include<stdio.h>...

Split string... tersely

Possible Duplicate: C#: Convert string to model Let's say I need to take a string and turn it into an array. This string has a single universal character to denote a new element. For example, I want to turn this string: var s = "first|second|third"; Into this array: var segments = new[] { "first", "second", "t...

How do I populate a NSMutableArray with UILabels?

I don't think I am creating this array of UILabels correctly. If I put a breakpoint after this line of code, it shows that the array is empty. colorLabelArray = [[NSMutableArray alloc] initWithObjects: greenLabel, orangeLabel, blackLabel,purpleLabel, yellowLabel, redLabel, blueLabel, whiteLabel, nil]; If I do the same thing with UI...