arrays

How to retrieve n characters from char array

i have a char array in a C app that i have to split into parts of 250 so i can send it along to another application that doesn't accept more at one time, how would i do that ? Platform: win32. Thanks in advance! ...

Slicing a multi-dimensional PHP array across one of its elements.

Say for example you just queried a database and you recieved this 2D array. $results = array( array('id' => 1, 'name' => 'red' , 'spin' => 1), array('id' => 2, 'name' => 'green', 'spin' => -1), array('id' => 3, 'name' => 'blue' , 'spin' => .5) ); I often find myself writing loops like this. foreach($results as $result) ...

Serialization of a long array (in C)

Hi, in a C program I have an long* that I want to serialize (thus converting to chars). A long doesn't fit in a single char, and the size varies depending of the processor (can be 4 bytes or 8 bytes). Theres a good way to make the serialization and de-serialization? ...

Kablammo! Explode function giving me a headache!

$array = explode(".", $row[copy]); $a = $array.length -1; I want to return the last element of this array but all i get from this is -1. Help would be much appreciated. ...

PHP Array, key without an assigned value

I am currently plowing my way through IBM's tutorial on CakePHP At one point I run into this snippet of code: <?php class Dealer extends AppModel { var $name = 'Dealer'; var $hasMany = array ('Product' => array( 'className' => 'Product', 'conditions'=>, // is this allowed? 'order'=>, // same thing here 'foreignKey'=>'dealer_id') ); } ?...

Language showdown: Convert string of digits to array of integers?

I was trying to convert a string containing only base 10 digits (e.g. "124890") to an array of corresponding integers (for given example: [1, 2, 4, 8, 9, 0]), in Ruby. I'm curious about how easily this can be accomplished in Ruby and in other languages. ...

Order dates by upcoming

So I build an array of various dates. Birthdays, anniversaries, and holidays. I'd like to order the array by which one is happening next, essentially sort October to September (wrapping to next year) so if my array is $a = ([0]=>"1980-04-14", [1]=>"2007-06-08", [2]=>"2008-12-25", [3]=>"1978-11-03") I'd like to sort it so it is ar...

What's better in regards to performance? type[,] or type[][]?

Is it more performant to have a bidemnsional array (type[,]) or an array of arrays (type[][]) in c#? Particularly for initial allocation and item access ...

What is the best way to add options to a select from an array with jQuery?

What is the best method for adding options to a select from a JSON array using jQuery? I'm looking for something that I don't need a plugin to do, but would also be interested in the plugins that are out there. ...

What's the maximum number of keys for an array in php

I'm writing a php script where I call $lines = file('base_list.txt'); to break a file up into an array. The file has over 100,000 lines in it, which should be 100,000 elements in the array, but when I run print_r($lines); exit; the array only contains 7280 elements. So I'm curious, WTF? Is there a limit on the amount of keys an...

KSH scripting: how to split on ',' when values have escaped commas? [solved]

I try to write KSH script for processing a file consisting of name-value pairs, several of them on each line. Format is: NAME1 VALUE1,NAME2 VALUE2,NAME3 VALUE3, etc Suppose I write: read l IFS="," set -A nvls $l echo "$nvls[2]" This will give me second name-value pair, nice and easy. Now, suppose that the task is extended so that ...

Java: Serializing Array of own Objects

Hello, i have an Array of Objects of my class: public class Message implements Serializable{ static final long serialVersionUID = -1L; private String receiver; //Empfänger private String sender; //Absender private String Betreff; private String content; private String timestamp; ...} I am able to safe it with an Object*Stream b...

PHP Arrays: A good way to check if an array is associative or sequential?

PHP treats all arrays as associative, so there aren't any built in functions. Can anyone recommend a fairly efficient way to check if an array contains only numeric keys? Basically, I want to be able to differentiate between this: $sequentialArray = array('apple', 'orange', 'tomato', 'carrot'); and this: $assocArray = array('fruit1'...

Object arrays in method signatures

Consider the following method signatures: public fooMethod (Foo[] foos) { /*...*/ } and public fooMethod (Foo... foos) { /*...*/ } Explanation: The former takes an array of Foo-objects as an argument - fooMethod(new Foo[]{..}) - while the latter takes an arbitrary amount of arguments of type Foo, and presents them as an array of Fo...

What is the best way to delete a value from an array in Perl ?

The array has lots of data and I need to delete two elements. Below is the code snippet I am using my @array = (1,2,3,4,5,5,6,5,4,9); my $element_omitted = 5; @array = grep { $_ != $element_omitted } @array; ...

How do I concatenate two multi-dimensional arrays in VB?

I've got this code: rs1 = getResults(sSQL1) rs2 = getResults(sSQL2) rs1 and rs2 and 2D arrays. The first index represents the number of columns (static) and the second index represents the number of rows (dynamic). I need to join the two arrays and store them in rs3. I don't know what type rs1 and rs2 are though. ...

How do I slice an array in Excel VBA?

What function can I use in Excel VBA to slice an array? ...

Python List vs. Array - when to use?

If you are creating a 1d array, you can implement it as a List, or else use the 'array' module in the STDLIB. I have always used Lists for 1d arrays. What is the reason or circumstance where I would want to use the array module instead? Is it for performance and memory optimization, or am I missing something obvious? ...

Java: Serializing beginner problem :-(

I want to save and store simple mail objects via serializing, but I get always an error and I can't find where it is. package sotring; import java.io.*; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; import com.sun.org.apache.bcel.internal.generic.INEG; public class storeing { public static vo...

STL non-copying wrapper around an existing array?

Is it possible to create an STL-like container, or even just an STL-style iterator, for an existing array of POD-type elements? For example, suppose I have an array of ints. It would be convenient to be able to call some of the STL functions, such as find_if, count_if, or sort directly on this array. Non-solution: copying the entire a...