arrays

Looping through Array PHP

Hi all, I'm trying to loop through a cURL array response to generate XML files. However, my generated files all seem to have exactly the same contents - I don't know if this is the right approach or if I should be using an array, but I can't seem to figure it out and could use some fresh eyes. Basically, I want each $playlist's contents...

MySQL/PHP Selecting only unique values from multiple columns and put them into seperate arrays

Using PHP and MySQL I'm trying to select unique values from multiple columns in a table (but not all the columns in the table) and put all the unique values from each column selected in its own array. The uniqueness of each columns values should be compared only to other values in the same column. The code below puts all the unique valu...

How to store a string from a text file in an array in C

I want to read a text file into a string array and be able to access the array contents through a loop. The code I have allows me to store only the last line of the text file instead of the entire file; where am I going wrong? #define MAX 10000 int main (int argc, char *argv[]) { FILE *fp; char str[MAX]; char *x[MAX]; i...

When you make an ArrayList without specifying the object type, does it create it automatically when you add the first object?

For example, instead of doing ArrayList<ClassName> variableName; you do ArrayList variableName; then later you add an object of type "ClassName" variableName.add(objectName); will that automatically set the type of your array as ArrayList<ClassName> ? ...

Array of ImageButtons, assign R.view.id from a variable

Hey there. My app is going to be using an array of 64 ImageButtons (8x8), and they're all already declared in my XML Layout with names like one1, two5, eight8, etc. Rather than declare these each individually in my Java I thought it might be smart to declare them all in some for loops. I have ImageButton musicGrid[][] = new ImageButton ...

How to search an array in Ruby?

Say I have an array of strings arr = ['sandra', 'sam', 'sabrina', 'scott', 'mark', 'melvin'] How would I search this array just like I would an active record object in Rails. For example, the query "sa" would return ['sandra', 'sam', 'sabrina']. Thanks! ...

Android - How do you pass a byte[] to a .net Webservice using HttpClient / HttpPost?

How can I call a Webservice with a byte[] parameter? Tried using the namedvaluepairs, but they take strings only. I am not using the Ksoap2, we decided to use the HttpClient / HttpPost method. Anyone have any ideas? Here is my code: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setCont...

invalid conversion from ‘char*’ to ‘char’ in C++

My code, when compiled, returns the error invalid conversion from ‘char*’ to ‘char’, and identifies the second last line, return char32 as the problem. I've searched internet and this site and haven't found anything that has helped. I've found the error goes away and the code compiles if I replace the problem line with return *char32, bu...

Groovy: remove and object from a list within itself?

I'm trying to remove objects from a list when it finds that particular objects privacy is private to the current user books.eachWithIndex{ obj, i -> if((obj.book.private).equals(true)){ def status = bookService.getBookStatus(obj.book) if(!status){ books.remove(i) } } ...

array of vehicles

is there anyone that can help me with java program I spent hour troubleshooting? I have no problem reading the file into a string array but I don't seem to know how to use switch or maybe if statement to store each line in an Array of Objects. Write an application with a main that reads a file (from the command line) and fills an ar...

C++ struct array copy

Guys, I want to copy elements of a struct array to another by using memcpy. I believe this is miserably causing my program to fail for some reason. Also how can I free the memory in the end ? struct FaultCodes { string troubleFound; string causeCode; string actionCode; string paymentCode; string suppCode; u_int16_t multipli...

How can I reverse a list in python?

How can i do this in python? array=[0,10,20,40] for (i = array.length() - 1 ;i >= 0; i--) I need to have the elements of an array but from the end to the beginning. ...

Find an array inside another larger array

Hi All, I was recently asked to write 3 test programs for a job. They would be written using just core Java API's and any test framework of my choice. Unit tests should be implemented where appropriate. Although I haven't received any feedback at all, I suppose they didn't like my solutions (otherwise I would have heard from them), so ...

Passing an array back to the server using JQuery .post()

There are loads of questions and answers regarding the issue of posting arrays back to the server using jquery. However I cant seem to find any solutiion to the problem I'm having. Basically the code below should return an array of ID's back to the server: I know the array contains items as the length of the array always matches the nu...

php array combine

I have the next array: Array ( [0] => Array ( [id] => 160 [payment_period] => Monthly [plan_payment_type_id] => 171 [payment_type_id] => 4 ) [1] => Array ( [id] => 160 [payment_period] => Monthly [plan_payment_type_id] => ...

PHP combining arrays.

How can I combine both of these arrays and if there is duplicates of an array have only one represented using PHP. Array ( [0] => 18 [1] => 20 [2] => 28 [3] => 29 ) Array ( [0] => 1 [1] => 8 [2] => 19 [3] => 22 [4] => 25 [5] => 28 [6] => 30 ) ...

WPF DataBinding specifying array index in Binding not working

I am facing a problem with DataBinding in WPF:::: The below code is working: <TextBox Text="{Binding ProcessStepBlock.ProcessStep[2].ProcessDescription}"></TextBox> <TextBox Text="{Binding ProcessStepBlock.SelectedIndex}" ></TextBox> The below code is not working:It gives me a binding error BindingExpression path error: '[ ]' prope...

javascript images array

hi, i'm trying to loop through all images on the page, should be easy but i can't see where im going wrong here. the imgs gets populated with the images but the imgs.length returns 0; its somethign stupid but i just cant figure it out. var imgs = document.getElementsByTagName('img'); console.log(imgs); console.log(imgs.length); if(imgs...

Array as class property ?

Hello, I have this API that requires me to have a specific array key to be send. Since that array needs to be used on ALL class methods, I was thinking on putting as a class property. abstract class something { protected $_conexion; protected $_myArray = array(); } Later on, on the methods of this class, I will then use: $t...

POST'ing arrays in WebClient (C#/.net)

Hi guys, I've got a .net application that has a WebRequest that to a POST adds multiple times the same key, thus making it an array in the eyes of PHP, Java Servlets etc. I wanted to rewrite this to using WebClient, but if I call WebClient's QueryString.Add() with the same key multiple times, it just appends the new values, making a com...