arrays

Web Service: Service Unavailable error

Hi, I have this web service to import data but I cant import data because i got an error "Service Unavailable" This is my request: POST /webservice/User.asmx HTTP/1.1 Host: www.sample.com.au Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://www.sample.com.au/UpdateUserBatch" <?xml version="1.0" encoding=...

Is instantiating a Queue using {a,b,c} possible in C#?

Is it possible to do that in C#? Queue<string> helperStrings = {"right", "left", "up", "down"}; or do I have to produce an array first for that? ...

Js RegExp every other character

I have random strings that are similar to this: 2d4hk8x37m or whatever. I need to split it at every other character. To split it at every character its simply: '2d4hk8x37m'.split(''); But i need every other character so the array would be like this: ['2d', '4h', 'k8', 'x3', '7m'] Your help is appreciated. Thanks! ...

How to check identical array in most efficient way?

Hi, I want to check if the two arrays are identical (not content wise, but in exact order). For example: array1 = [1,2,3,4,5] array2 = [1,2,3,4,5] array3 = [3,5,1,2,4] Array 1 and 2 are identical but 3 is not. Is there a good way to do this in JavaScript? ...

Ruby: Apply gsub to first and second array items

I have the follow line: text.gsub(/,\ /,'| ').first But in addition to the first item, I want to apply it to the second item. How can I do that? ...

JS / jQuery: Already in array?

I'm trying to find out the best way to check if an item is already in an array. I have a number of checkboxes that belong to 1 of 5 groups. When a user clicks on one of these checkboxes, a second and third list that belong to one of the groups is written to the page. What I'm trying to do is add these groups to an array, and once they'...

javascript/jQuery: how do you dynamically turn attribute values into object keys?

Here is my problem, I have a whole bunch of elements that look like this... <input type="email" id="email" data-item="email" data-key="contact_details"/> <input type="tel" id="mobileNo" data-item="mobileNo" data-key="contact_details"/> <input type="text" id="sleeve_length" data-item="sleeve_length" data-key="measurements"/> <input type...

php+mysql: insert a php array into mysql

Hi I have an array with 30000 plus entries that need to go into a MySQL table. What is the best practice? From here? Lets say [0], [1] and [2] in the database would be 'title', 'type' and 'customer' Is it add key names matching the column names in the table and call som "magic" function? Or build the query manually... Array ( [0]...

Array to Hash Ruby

Okay so here's the deal, I've been googling for ages to find a solution to this and while there are many out there, they don't seem to do the job I'm looking for. Basically I have an array structured like this ["item 1", "item 2", "item 3", "item 4"] I want to convert this to a Hash so it looks like this { "item 1" => "item 2", "...

Return SQL Query as Array in Powershell

I have a SQL 2008 Ent server with the databases "DBOne", "DBTwo", "DBThree" on the server DEVSQLSRV. Here is my Powershell script: $DBNameList = (Invoke-SQLCmd -query "select Name from sysdatabases" -Server DEVSQLSRV) This produces my desired list of database names as: Name ----- DBOne DBTwo DBThree I has been my assumption that a...

[Groovy] Searching for the contents of an Array in another array

Hi folks, I'm using groovy in SOAPUI and am currently trying establish whether the response from 2 endpoints yields the same results. I'm converting my XML response into an array for each endpoint and then looping through Array1 and then Array2 to confirm the presence of each item in Array1. This is very ugly code and I did look at m...

How can I create a time-series bar graph in Ruby on Rails with a hash?

I am able to create a time-series "hash" using the statistics gem: => #<OrderedHash {"2010-10-23"=>2, "2010-09-22"=>3, "2010-09-11"=>1, "2010-08-27"=>1, "2010-10-15"=> 1, "2010-09-15"=>1, "2010-08-08"=>2, "2010-10-17"=>14, "2010-10-06"=>2, "2010-09-28"=>1, "2010-10-19 "=>1, "2010-09-20"=>1}> I want to create a simple graph with this d...

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 to sort associative array in Javascript?

Hi, I need to sort associative array by JS for one of my projects. I found this function, that works great in firefox, but unfortunately it doesnt work in IE8, OPERA, CHROME... Cant find the way to make it work in other browsers, or find another function that would fit the purpose. I really appreciate any help. function sortAssoc(aInpu...

Picking the nearest value from an array reflecting ranges

I have an array that reflects rebate percentages depending on the number of items ordered: $rebates = array( 1 => 0, 3 => 10, 5 => 25, 10 => 35) meaning that for one or two items, you get no rebate; for 3+ items you get 10%, for 5+ items 20%, for 10+ 35% and so on. Is there an elegant, one-line way to get the correct rebat...

converting string containing keys and values into array

does anyone know an elagant way of turning this string (the list is not definite.. the "keys" and "values" can be added arbitrarily) business_type,cafe|business_type_plural,cafes|sample_tag,couch|business_name,couch cafe into this array? array( [business_type]=>'cafe' [business_type_plural] => 'cafes' [sample_tag]=>'co...

Converting a 2d array of ints to char and string in Java

How can i convert the ints in a 2d array into chars, and strings? (seperately) If i copy ints to a char array i just get the ascii code. For example public int a[5][5] //some code public String b[5][5] = public int a[5][5] Thanks ...

Format array items for string output.

I'm trying to display the items in an array using the following: NSString *alertString = [NSString stringWithFormat:@"%@", path]; Which works fine, but when I display the string it gets displayed in the following way: ( A, B, C, D ) Is there a way to get it to display in a different way, such as all on one line and without brackets,...

Windows Forms program runs smoth on win7 but on previous os's give the "Index was outside the bounds of the array" Error?

I have a Windows Forms program that runs smooth on win7 but on previous version of windows give the "Index was outside the bounds of the array" error in the imageList call when setting the key-image of the component. Why this can be hapening? PS: This only occur when running the .exe, not when debugging. ...

Accessing a class object in PHP

Does anyone has idea how to access HREF from the below object: SimpleXMLElement Object (    [@attributes] => Array        (            [title] => Preview            [rel] => enclosure            [type] => image/jpeg            [href] => http://a1.phobos.apple.com/us/r1000/008/Purple/94/ee/38/mzl.fupornmt.320x480-75.jpg        ) ...