arrays

Updating Twitter background via API

I'm having a little trouble updating backgrounds via Twitter's API. $target_url = "http://www.google.com/logos/11th_birthday.gif"; $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_URL,$target_url); curl_setopt($ch, CURLOPT_FAILONERROR, tr...

how to tokenize string to array of int in c?

Anyone got anything about reading a sequential number from text file per line and parsing it to an array in C? What I have in a file: 12 3 45 6 7 8 3 5 6 7 7 0 -1 4 5 What I want in my program: array1[] = {12, 3, 45, 6, 7, 8}; array2[] = {3, 5, 6, 7}; array3[] = {7, 0, -1, 4, 5}; I've been through several ways to read it, but the ...

using sscanf(), read string to array of int?

i have this string: 12 4 the quick 99 -1 fox dog \ what i want in my program: myArray[] = {12, 4, 99, -1}; how i do a multiple number scanning? ...

what is the cleanest way to remove all extra spaces from a user input comma delimited string into an array

A program has users typing in a comma-delimited string into an array: basketball, baseball, soccer ,tennis There may be spaces between the commas or maybe not. If this string was simply split() on the comma, then some of the items in the array may have spaces before or after them. What is the best way of cleaning this up? ...

Java: Max/min value in an array?

It's trivial to write a function to determine the min/max value in an array, such as: /** * * @param chars * @return the max value in the array of chars */ private static int maxValue(char[] chars) { int max = chars[0]; for (int ktr = 0; ktr < chars.length; ktr++) { if (chars[ktr] > max) { max = chars[ktr]; } } return ma...

Split String in C# without delimiter (sort of)

Hi, I want to split a string in C#.NET that looks like this: string Letters = "hello"; and put each letter (h, e, l, l, o) into an array or ArrayList. I have no idea what to use as the delimiter in String.Split(delimiter). I can do it if the original string has commas (or anything else): string Letters = "H,e,l,l,o"; string[] AllLett...

jQuery arrays and retrieve data and key

Hi all. I am new to jQuery and just wrote this small piece (with PHP knowledge) and was wondering a) would it work b) how would i return a value acording to its key value? var boxHeightArray = []; var boxNameArray = []; $("div[class=dropDiv]").each(function(i){ var height = $(this).height(true); var name = $(t...

Process Large Textfiles Quickly w/ VBA

Hey Everyone, I'm having a hardtime speeding up the processing of a very large textfile (~100 Meg or so). I've made caution to be very diligent using the redim preserve calls, and yet the function still takes 5 minutes or so to run. The textfile is basically sub reports which i'm trying to parse out. I only have access to the large f...

Variable parameter class?

The following code public static void main(String[] args) { fun(new Integer(1)); } static void fun(Object ... a) { System.out.println(a.getClass()); } gives the output :- class [Ljava.lang.Object; What class is this? ...

Sort a set of <li>'s alphanumerically.

I've been playing around trying to get a function that will sort a selection of li tags by their content but currently to no avail (at least no speed/accuracy); $('.sortasc').live('click',function(){ var liArr = Array(); $('#licontainer').children('li').each(function(){ liArr.push($(this).html()); })...

Can E4X Have An Array Passed To It?

Hi All, Say we have the following XML: <people> <person> <name>Jake</name> <skills> <skill>JavaScript</skill> <skill>HTML</skill> <skill>Flex</skill> <skill>CSS</skill> </skills> </person> <person> <name>John</name> <skills> <skill>C++</skill> <skill>Foxpro</skill> </skills> </person> <person> ...

How does one instantiate an array of maps in Java?

I can declare an array of maps using generics to specify the map type: private Map<String, Integer>[] myMaps; However, I can't figure out how to instantiate it properly: myMaps = new HashMap<String, Integer>[count]; // gives "generic array creation" error myMaps = new HashMap[count]; // gives an "unchecked or unsafe operation" warnin...

Is there a function to extract a 'column' from an array in PHP?

I have an array of arrays, with the following structure: array(array('page' => 'page1', 'name' => 'pagename1') array('page' => 'page2', 'name' => 'pagename2') array('page' => 'page3', 'name' => 'pagename3')) Is there a built-in function that will return a new array with just the values of the 'name' keys? so I'd get: arra...

Something like mapM, but for arrays? (like arrayMap, but mapping an impure function)

Hello, I see that I can map a function over mutable arrays with mapArray, but there doesn't seem to be something like mapM (and mapM_). mapArray won't let me print its elements, for example: import Data.Array.Storable arr <- newArray (1,10) 42 :: IO -- answer to Life, Universe and Everything x <- readLn :: IO Int mapArray (putStrLn.s...

JavaScript Array Iteration returning more than values

Hello, This is so simple I am baffled. I have the following: var x = 'shrimp'; var stypes = new Array('shrimp', 'crabs', 'oysters', 'fin_fish', 'crawfish', 'alligator'); for (t in stypes) { if (stypes[t] != x) { alert(stypes[t]); } } Once the values have iterated it starts returning a dozen functions like functi...

Abbreviation for PHP's array()

I don't know how about you, but I'm not very fond of the way arrays are constructed in PHP. I have this feeling that I use array keyword way too often and that array($k => $v) or e.g. array($k1=>array($k2=>$v)) are way too long given usefulness of maps. (Moreover, recently I've learned JS way of doing it and now I really am jealous) The...

Check Upload file type from an array in PHP.

Hi, I know this has been asked a few times before. However, it's something I've had a problem with for a long time. How can I check if a file extension and mime type are in an array this is the code I currently have. $upload_project_thum = $_FILES['upload_project_thum']['name']; $upload_project_thum_ext = substr($upload_project_thum...

PHP: How to sum values of the array of the same key

Hello, How can I add all the values of the key gozhi? Note that 'gozhi' key is dynamic. <?php Array ( [0] => Array ( [gozhi] => 2 [uzorong] => 1 [ngangla] => 4 [langthel] => 5 ) [1] => Array ( [gozhi] => 5 [uzorong] => 0 ...

How to sort structure arrays in MATLAB?

I'm working with an image retrieval system using color histogram intersection in MATLAB. This method gives me the following data: a real number which represents the histogram intersection distance, and the image file name. Because they are different data types, I store them in structure array with two fields, and then I save this structu...

Passing arrays into testclass constructors

lo. first time posting on stack. im trying too just do some past exam questions but its proving difficult so sorry if this sounds noobish. i need too pass a 1d array that isnt defined in a method. i need too create a testclass then make the arrays myself. im just not sure about the syntax. example heres my company class public clas...