arrays

How to sort a PHP by date

Here is my array: Array ( [0] => Array ( [0] => content here [1] => 2010-02-04 01:25:34 ) [1] => Array ( [0] => content here [1] => 2010-02-04 04:51:37 ) [2] => Array ( [0] => content here [1] => 2010-02-04 04:52:31 ) [3] => Array ( [0] => content here [1] => 2010-02-04 05:50:48 ) [4] => Array ( [0] => content he...

which is more efficient for buffer manipulations: python strings or array()

I am building a routine that processes disk buffers for forensic purposes. Am I better off using python strings or the array() type? My first thought was to use strings, but I'm trying to void unicode problems, so perhaps array('c') is better? ...

java: Deleting Element from Array after .split()

Suppose you have a String[] that has been created after a .split() which then causes you to have a bunch of empty strings in there i.e. myArray['','hello','thetimes','economist','','','hi'] Is there a way to remove them from the String[] without having to loop round, detecting if string is empty then adding to new array? ...

How do you declare a const array of function pointers?

Firstly, I've got functions like this. void func1(); void func2(); void func3(); Then I create my typedef for the array: void (*FP)(); If I write a normal array of function pointers, it should be something like this: FP array[3] = {&func1, &func2, &func3}; I want to make it a constant array, using const before "FP", but I've got...

Best way to check an array value with for statement

Hi, I'd like to check if there is a value on an array like this: function check_value_new ($list, $message) { foreach ($list as $current) { if ($current == $message) return true; } return false; } function check_value_old ($list, $message) { for ($i = 0; $i < count ($status_list); $i ++) { if ($status_li...

Why am I getting the "Duplicate variable definition" error here?

It think Flash is telling me that my array tabData is getting duplicated, but I only set it up once in the var section of my code: This is the line with the error: for (var i in tabData) { TabMenu class private var tabData:Array = []; // <- tabData created here public function drawTabMenu(w, h, color, videoHDiff, ypos):void {...

Passing arrays to variable length argument lists

If I have a function void Foo(params int[] bar){} The following runs fine: int[] a1 = {1, 2, 3}; int[] a2 = {4, 5, 6}; Foo(1, 2, 3); Foo(a1); But these give compile errors: Foo(a1, 1, 2, 3); Foo(1, 2, a1); Foo(1, a1, 2); Foo(a1, a2, 1, 2, 3); because only the first argument is allowed to be an int[], the rest have to be ints. ...

Object reference not set to an instance of an object.

I have a class Cell: public class Cell { public enum cellState { WATER, SCAN, SHIPUNIT, SHOT, HIT } public Cell() { currentCell = cellState.WATER; MessageBox.Show(currentCell.ToString()); } public cellState currentCell { get; set; } } I then try to u...

How can I create an Array of Controls in C#.NET?

I have a form which contains several standard controls (textbox's, buttons, etc). I want to group certain controls in collections so that I can enable and disable them at any given time without having to explicitly set each one. What is the syntax to do that? Here is some pseudo code to show what I want to do.... Control[] ControlCollec...

Why can't I set zero as the first key in the array?

The result of this code: for($i = 0; $i <= 7; $i++){ $eachone[] = array ('a' => '1', 'b' => '2', 'c' => '3'); $a[] = array($i => $eachone); unset($eachone); } $json_string = json_encode($a); echo $json_string; is: [ [ [ { "a": "1", "b": "2", "c": "3" ...

What is the difference between Array() and [] in Javascript and why would I use one over the other?

Possible Duplicate: What’s the difference between Array() and [] while declaring a JavaScript array? In JavaScript you can create a new array like: var arr = new Array(); or like: var arr2 = []; What is the difference and why would you do one over the other? ...

List parameters in recursive calls (C)

I'm designing a recursive algorithm : int f(int[] a, int[] b){ ----changing a here ----changing b here f(a,b) ----writing a here ----writing b here } I know all arrays are pointers so this code should be problematic. It'll write the final values of a and b after all the recursive calls finished. I dont want that to happen. What shoul...

dynamic char array sizing

Hello, In my application, I have a char array defined which can take one of three options: "okay", "high", "low" which are then sent down a serial port to a remote device. I currently have the array sized to take the 4 character words plus carriage return and line feed, but when I have to send "low" I get a null character in the string...

Is it possible to pass a javascript array through GET and access it through $_GET at the other end..?

Hi all... I have a javascript array say jsArr[]. I want this array to be passed to a php page through the get method. Something like "nextPage.php?arr=jsArr[]". There i should be able to access the array like "$arr[] = $_GET[arr]" and perform operations like foreach($arr as $key => $val). Is it possible...? Thanks a lot in advance.....

jquery array/call function from array in order

Hi. I am working on a project where I have a bunch of functions that I would like to call one by one in a particular order when a button is clicked. Once one function has been performed I do not want to use again I would like to move onto the next one. It has been suggested by another S.O user that I need to use arrays but I am still le...

easy way to randomize the entries of an array using stl?

Hi, I can sort a int* array using stl, plain and simple like std::sort(myarray, myarray + size); Is there any equal simple way to randomize it? thanks ...

Is there a built in way to get an array out of multi dim array in PHP?

(Very useful when querying DB). If I have a multy dim array [['id'=>1],['id'=>2],['id'=>34],['id'=>67]] and what I want is [1,2,34,67] I know how to do it in code, just asking if there is a built in way in PHP (or may be in PDO) to do this. ...

Producing 2D array from a 1D array in MATLAB

Does anyone know if there is a way to produce a 2D array from a 1D array, where the rows in the 2D are generated by repeating the corresponding elements in the 1D array. I.e.: 1D array 2D array |1| |1 1 1 1 1| |2| |2 2 2 2 2| |3| -> |3 3 3 3 3| |4| |4 4 4 4 4| |5| |5 5 5 5 5| ...

Problem trying to dynamically create a tabbed navigation with dynamic text

Hi everyone, I'm creating a tabbed navigation from an XML file. However for some reason my loop only creates textfields for the active tab and the last tab (in this case the 4th tab). > You can preview my Flash here. < (I turned textfield borders on) My Issues: 1. The Active Tab (light colored tab) does not size correctly based on ...

Creating a 2D String Array from a ArrayList

I have a array list of objects (<ArrayList> Cars) which contains two single elements. These elements are New Car Model[name=Prius, manufacturer=Toyota, year=2001] and New Car Model[name=Panda, manufacturer=Fiat, year=2005;]. I would like to create a two dimensional String array (in this case String [2][3] Cars] where to each car would co...