arrays

Objective-C - Parsing a CSV into a array

How would I parse a CSV into an array. Its only a one column spread sheet I converted into an CSV so it shouldn't be too hard right? Any way how do I do this? ...

How to check if a string is in an array

I basically need a function to check whether a string's characters (each character) is in an array. My code isn't working so far, but here it is anyway :| $allowedChars = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"," ","A","B","C","D","E","F","G","H","I","J","K","L","M",...

Permutating through the array of chars

Suppose you need to discover all possible permutations of 'n' distinct characters, say 'a', 'b', 'c'. Can you suggest an algorithm I can use to get this done? Generally speaking, how would you go about it? ...

Array sum of value based on same key

I have my array data as shown below: Array ( [0] => Array ( [name] => Bank BRI [amount] => 0 ) [1] => Array ( [name] => Bank BRI [amount] => 0 ) [2] => Array ( [name] => Bank BCA [amount] => 1412341234 ) [3] => Array ( [name] => Bank CIMB Niaga [amount] => 532532552 ) [4] => Array ( [name] => Bank BRI [amount] => 34534534 ...

Transform Javascript Array into delimited String

I have a Javascript string array with values like A12, B50, C105 etc. and I want to turn it into a pipe delimited string like this: A12|B50|C105... How could I do this? I'm using jQuery (in case that helps with some kind of builtin function). ...

Use the value of a string variable as the 'index' of an existing object in Javascript

I am using Javascript. I have var myobj = { "one": { "name" : "paul", "no" : "A123" }, "two": { "name" : "mike", "no" : "B456" }, "three": { "name"...

is it possible to use bash to access more than one array in a for loop

I'm trying to write a bash script that will let me download multiple web pages using curl. For each webpage, I want to be able to pass curl the page and the referer link. I want to be able to supply multiple webpages at once. In other words, I want to be able to loop through the webpages I supply the script, and for each page, pass the ...

Pointers in structs passed to CUDA

Hi folks, I've been messing around with this for a while now, but can't seem to get it right. I'm trying to copy objects that contain arrays into CUDA device memory (and back again, but I'll cross that bridge when I come to it): struct MyData { float *data; int dataLen; } void copyToGPU() { // Create dummy objects to copy int ...

Make array of all GET-variables

Hey. I'm trying to get an array of all GET-variables passed to a PHP document. Is this possible? Thanks. :) ...

rails - converting an object to an array

Hey, I am trying to convert this object to an array of ints e.g. array(3,4,6) - - !ruby/object:Code attributes: candidate_id: "3" attributes_cache: {} - !ruby/object:Code attributes: candidate_id: "4" attributes_cache: {} - !ruby/object:Code attributes: candidate_id: "6" attributes_cache: {} here is what I tried result ...

PHP: merge two arrays while keeping keys instead of reindexing?

how can i merge two arrays (one with string => value pairs and another with int => value pairs) while keeping the string/int keys? none of them will ever overlap (because one has only strings and the other has only integers). here is my current code (which doesn't work, because array_merge is reindexing the array with integer keys): //...

Trying to modify an array to avoid overlapping key-value pairs using PHP

Hi everyone, I have an array that looks like this: Array([5258]=>5274, [5261]=>5281, [5264]=>5287, [5271]=>5289 ); I want to modify this array so that any overlaps in key value pairs are removed. To elaborate, the first key value pair should become [5258]=>5289, because the numerical value of the each of the rest ...

How can I dynamically name an array in Javascript?

I am using jQuery and JSON to pull data from a database. Each row of the database is a different product and each product has a number of properties associated with it. What I'm trying to do in js, is create a named array for each product containing all of the products properties. I know how to pull the data from JSON. I know how to con...

Negotiate arrays inside an array

When i perform a regular expression preg_match_all('~(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)~', $content, $turls); print_r($turls); i got an array inside array. I need a single array only. How to negotiate the arrays inside another arrays ...

How do I fix this lvalue warning?

My code is: void main() { person student[10]; student[0].names[0] = 'C'; student[0].names[1] = 'a'; student[0].names[2] = 'm'; student[0].names[3] = 'i'; student[0].ages = 16; student[0].sex[0] = 'F'; student[0].sex[1] = 'e'; student[0].sex[2] = 'm'; student[0].sex[3] = 'a'; student[0].sex[4] = 'l'; student[0].sex[5] = 'e';...

The easiest way to transform collection to array?

Suppose we have a Collection<Foo>. What is the best (shortest in LoC in current context) way to transform it to Foo[]? Any well-known libraries are allowed. UPD: (one more case in this section; leave comments if you think it's worth to create another thread for it): What about transforming Collection<Foo> to Bar[] where Bar has construc...

Java reading JSON null

OK, I am getting null for whatever reason I cannot fathom. Here is my code: import java.util.*; import java.io.*; import com.google.gson.*; public class readGoogle { public static String MapTitle; public static Data data; public static Item item; public static String dan; public static FileReader fr; pu...

Can't count an array in PHP

I've encountered a very odd issue in a class I'm creating. Here is a snippet of the class below and it's output: class WeirdHappenings { protected $filters_list = array(); ... function build() { $filters_count = count($this->filters_list); echo "<pre>"; var_dump($this->filters_list); echo "...

Initialization strings in C

Hi all. I have a question about how is the correct way of manipulate the initialization of c strings For example the next code, isn't always correct. char *something; something = "zzzzzzzzzzzzzzzzzz"; i test a little incrementing the number of zetas and effectively the program crash in like about two lines, so what is the real size li...

Accessing data from an Array of dicionaries containing an array

Hi, I'm a bit stumped and I'm hoping someone can help me. I've got a plist which is an array of dictionaries. I'm trying to read it into a table. The plist looks like this: <array> <dict> <key>sectionTitle</key> <string>A</string> <key>rowData</key> <array> <dict> <key>T...