arrays

How to declare an array in Java?

How do I declare an array in Java? ...

PHP - Merge two arrays (same-length) into one associative?

Hi, pretty straightforward question actually.. is it possible in PHP to combine two separate arrays of the same length to one associative array where the values of the first array are used as keys in the associative array? I could ofcourse do this, but I'm looking for another (built-in) function, or more efficient solution..? fun...

Using glTexSubimage2d with a dynamically sized texture array

Have anyone tried this (stackoverflow.com/questions/679210/how-can-i-use-a-dynamically-sized-texture-array-with-glteximage2d) with glTexSubImage2D instead? I really need it and I can't put it to work properly, all I get is a striped, funny coloured square on my original texture. Thanks in advance. ...

Array.Split() with square brackets[], from the Advanced Actionscript Animation book

I'm trying to understand how this piece of code from Keith Peter's Advanced Actionscript works. Essentially there's a for loop going on to split key/value pairs seperated by :. Here's the code: var definition:Object = new Object(); for(var i = 0;i < tokens.length; i++) { var key:String = tokens[i].split(":")[0]; var val:String...

What is the best way to check if an object is an array or not in Javascript?

Say I have a function like so: function foo(bar) { if (bar > 1) { return [1,2,3]; } else { return 1; } } And say I call foo(1), how do I know it returns an array or not? ...

How to initialize SecureString for readonly

I would like to create a variable, a secure one, that is more or less a CONST to use in my code. I've looked into using System.Security.SecureString, and that looks like it could be the ticket as I don't want the user to find out this password. The only problem comes with initializing it. In most cases, it looks like the SecureString ...

Shorten array in PHP: 20 values => X values

Hello! In PHP I have an array containing 20 elements or more. The keys have been assigned automatically. The values are random numbers from 1 to 50. <?php $randomList = array(); for ($i = 0; $i < 20; $i++) { $randomList[] = mt_rand(1, 50); } ?> Now I want to plot this array into a line chart. Unfortunately, I can only use 5 points ...

How can I assign a property to a jQuery object?

Hi, It is in my understanding that referencing any DOM element in jQuery via the dollar sign (like this: $("#mydiv")), returns an object. I am looking to add an additional property to an object as such: $("#mydiv").myprop = "some value"; but this does not seem to work. I am trying to store a value in this object so I can reference it...

Iterating through a PHP array in jQuery?

How do I iterate through a PHP array in jQuery? I have an array in php named $viewfields. How do I iterate through each element of this array using jQuery? EDIT 1 <?php foreach ($viewfields as $view): ?> if(<?=$view['Attribute']['type'];?>=='text'||<?=$view['Attribute']['type'];?>=='number') { $("<input id=input<?=$v...

Puzzling javascript array behavior

So, this may be a really stupid question, but I'm obviously missing something here. Consider the following code: var selectedItems = []; selectedItems.push("0ce49e98-a8aa-46ad-bc25-3a49d475e9d3"); //fyi, selectedItems[selectedItems.length] = "0ce49e98-a8aa-46ad-bc25-3a49d475e9d3"; produced the same result. At the end sel...

iPhone|UIWebView: tabbed browsing by using NSArray?

I want to code a small tabbed browser just for the fun. However I'm not sure how the tabbed thing works. So this might be a noobish question: can I store a current webView in an array? using: [array addObject:webView]; and if yes how do I load it into the webView again? maybe using: webView = [array objetAtIndex:anIndex]; will it appe...

Using numpy to build an array of all combinations of two arrays

Hi, I'm trying to run over the parameters space of a 6 parameter function to study it's numerical behavior before trying to do anything complex with it so I'm searching for a efficient way to do this. My function takes float values given a 6-dim numpy array as input. What I tried to do initially was this: 1) First I created a functio...

Looping through mysql_fetch_array in PHP

So I have the following: $i = 0; $records = mysql_num_rows($sections_query); $row_sections = mysql_fetch_array($sections_query); foreach ($row_sections as $value) { echo $value . "<br />"; } The value of $records becomes 4 after execution and the DB has 2 columns per row. The first column value is 'section_id' and the second ...

See if a variable is an array using JavaScript

Possible Duplicates: How do you check if a variable is an array in JavaScript ? What is the best way to check if an object is an array or not in Javascript? How can i tell if a javascript variable is an array? ...

What is the Cost of Calling array.length

While updating for loops to for-each loops in our application, I came across a lot of these "patterns": for (int i = 0, n = a.length; i < n; i++) { ... } instead of for (int i = 0; i < a.length; i++) { ... } I can see that you gain performance for collections because you don't need to call the size() method with each loop. ...

Whats wrong with this array? Whenever I run the action it locks up.

Why isn't this code working? The app loads fine, however whenever I press the button the application locks up (doesn't crash) and returns me to Xcode and there is a red arrow pointing to one of the lines (Indicated on the line below). I also get three warnings (not errors), one says 'NSMutableArray' may not respond to '-objectAt:' and t...

Does PHP's ArrayObject have an in_array equivalent?

PHP has an in_array function for checking if a particular value exists in an native array/collection. I'm looking for an equivalent function/method for ArrayObject, but none of the methods appear to duplicate this functionality. I know I could cast the ArrayObject as an (array) and use it in in_array. I also know I could manually iter...

abstract function pointers

How would I create an array of ten function pointers? What I have is a for loop, and I want to set a function pointer to a different function on each iteration. so: //pseudocode for i (0..10) function = array_of_functions[i]; //... ...

How can I turn a list of items into a php array?

word 1 word 2 word 3 word 4 And so on... How can I turn that into a php array, here will be a lot of items so I don't want to write them all out into an array manually and I know there has to be a simple way I mean do I have to do <?PHP $items = array(); $items['word 1']; $items['word 2']; $items['word 3']; $items['word 4']; ?> UP...

How to build this php array?

$items = "word1 word2 word3 word4"; $items = explode(" ", $items); $items is my array, how can I have it turn into this Like how can I make word1 be a key and a value? "word1" => "word1" ...