arrays

How to print multiple arrays of different types in Java?

How do i print out multiple arrays, with my code below i only get the double array printed out? import javax.swing.JOptionPane; public class Matriseoppgave { public static void main(String[] args) { JOptionPane.showMessageDialog(null, "Du skal nå skriv inn 3 navn"); String getnavn1 = JOptionPane.showInputDialog("Skriv inn...

java - passing array in oracle stored procedure

Hi, I have a Java app accessing an oracle stored procedure. The arguments to the stored procedure include an array type. I do it like the following... con = this._getConnection(); Connection narrowdConn = (Connection)WSJdbcUtil.getNativeConnection( (WSJdbcConnection)con ); callable = con.prepareCall("{call MY_PKG.MY_PROCEDURE(?, ?...

ruby object array... or hash

I have an object now: class Items attr_accessor :item_id, :name, :description, :rating def initialize(options = {}) options.each { |k,v| self.send( "#{k.to_s}=".intern, v) } end end I have it being assigned as individual objects into an array... @result = [] some loop>> @result << Items.new(opt...

Count occurances in string from keyword array in javascript

I have an array: var locations = ['Afghanistan','Albania','Algeria','New York']; and a string: var string = 'I love Afghanistan New York Afghanistan Andorra Andorra Algeria New York'; I want to count the number of times each keyword in the array appears in the string but can't figure out the best way to do that. ...

PHP Array and ArrayObject

which one should be used to manipulating data, Array or Array Object? Like search,sort and other array manipulations. ...

Moving array items around

Here's my array: [2555] => Array ( [0] => stdClass Object ( [meta_id] => 1246 [post_id] => 2555 [meta_key] => event_date [meta_value] => Sept 24th - 29th ) [1] => stdClass Object ...

Arrays in Oracle SQL

Here's a simplified pseudo-code version of what I'd like to be able to do in PL-SQL (Oracle): DECLARE mylist as ARRAY BEGIN mylist (1) := '1' mylist (2) := '3' ... SELECT * FROM aTable WHERE aKey IN mylist; END; The SELECT should return the matching records for mylist(1), mylist(2) etc. It should be similar to ORing all ...

Passing an int array of variable length as a function parameter in Objective C

I have the following code which works fine... int testarr[3][3] = { {1,1,1}, {1,0,1}, {1,1,1} }; [self testCall: testarr]; Which calls this function: - (void)testCall: (int[3][3]) arr { NSLog(@"cell value is %u",arr[1][1]); } I need the array to be of variable length - What is the best way to declare the function? Us...

basic php problem I think answer will involve arrays

I want to make a conditional if statement that does this if($get_['b']=="1") { $offer1a=$offer1XXX; $offer1e=$offer1YYY; $offer2a=$offer2XXX; $offer2e=$offer2YYY; $offer3a=$offer3XXX; $offer3e=$offer3YYY; $offer4a=$offer4XXX; $offer4e=$offer4YYY; } All the way to offer #12. It seems like a lot to write out. There are other valu...

String from byte array doesn't get trimmed in C#?

Hello :) I have a byte array similar to this (16 bytes): 71 77 65 72 74 79 00 00 00 00 00 00 00 00 00 00 I use this to convert it to a string and trim the ending spaces: ASCIIEncoding.ASCII.GetString(data).Trim(); I get the string fine, however it still has all the ending spaces. So I get something like "qwerty.........." (where d...

How do you dynamically allocate a matrix?

How do you dynamically allocate a 2D matrix in C++? I have tried based on what I already know: #include <iostream> int main(){ int rows; int cols; int * arr; arr = new int[rows][cols]; } It works for one parameter, but now for two. What should I do? ...

strange behavior of php array_unique

I'm using following peace of code to output an array: echo "======output without array_unique====="; var_dump($selected); echo "=====output with array_unique====="; var_dump(array_unique($selected));die; And the output is: ======output without array_unique===== array 0 => array 'uri' => string 'http://localhost/conferen...

PHP: Built-in function to check whether two Array values are equal ( Ignoring the Order)

Is there a built-in function for PHP for me to check whether two arrays contain the same values ( order not important?). For example, I want a function that returns me true for the following two inputs: array('4','5','2') array('2','4','5') Edit: I could have sorted the two arrays and compare them, but as I am such a lazy guy, I wou...

PHP Array_Sum on multi dimensional array

If I have a multi dimensional array in PHP like so... [0] => Array ( [url] => http://domain1.com [domain] => domain1.com [values] => Array ( [character_length] => 25 [word_count] => 7 ) ) [1] => Array ( [url] => http://domain2.c...

one line ruby array creation and population...

This is fairly trivial, but it bothers me to no end that I haven't yet found the answer using Google or this forum. But how can i turn this into one line? Without have to declare rooms an array above? rooms = [] hwdata.availability.each {|room| rooms << room.name} ...

split <b>'s in php

For this code i need to take a string like <b>hey</b> more text<b>hey2</b> other text and i expect the returned array to look like <b>hey</b> more text <b>hey2</b> other text However it doesnt. How do i make it look like the above? my test code is $myArr = split("<b>", "<b>hey</b> more text<b>hey2</b> other text"); foreach($myArr ...

Array to create dates

I want to create an array using PHP that can be used in MySQL. My query looks like this... select name, sum(if (tdate='2009-09-09', amount, 0) as day1, sum(if(tdate='2009-09-10', amount, 0) as day2 ... ... sum(if(tdate='2009-10-01', amount, 0) as day23 from revenue group by name; The date range may change but ...

What's the most elegant method for determining if an array is associative or not?

I have some code that may be passed either an indexed array of values, or an associative array of value pairs. (The parameter is then used to construct radio buttons.) What's the most elegant (least resource hungry?) method for determining which I have? EDIT: One slight problem with this: what if the array to be tested is as follows.......

ASP.NET MVC - How to pass an Array to the view?

Hello there, I'm struggling myself here, to find a easy way to pass an array from the controller to the view on ASP.NET MVC framework. so in my controller I would have something like: public class HomeController : ApplicationController { public ActionResult Index() { string[] myArray = { "value01", "value02", "value0...

PHP - Multi dimensional SESSION array a good or bad idea for performance?

Are there any reasons not to want to use a multi dimensional SESSION array to store temporary user data? ...