arrays

Pushing reference of an object to array

As far as i can see in a situation like this: var x = []; var y = {}; y.someProp='asd'; This doesnt work: x.push(y); What I want to do is add a reference of y to x so that later if I will "delete y;" I want it also to be removed from the array x. ...

PHP - not returning a count number for filled array...

Morning, this is eating me alive so Im hoping it's not something stupid, lol. $arrg = array(); if( str_word_count( $str ) > 1 ) { $input_arr = explode(' ', $str); die(print_r($input_arr)); $count = count($input_arr); die($count); above is part of a function. when i run i get; > Array ( > [0] => luke > [1] => s...

Read from a file into an array and stop if a ":" is found in ruby

Hi! How can I in Ruby read a string from a file into an array and only read and save in the array until I get a certain marker such as ":" and stop reading? Any help would be much appreciated =) For example: 10.199.198.10:111 test/testing/testing (EST-08532522) 10.199.198.12:111 test/testing/testing (EST-08532522) 10.199.198.13:11...

PHP Sort Array based on values in another.....

Possible Duplicate: PHP - sort an array based on another array? Need some help regarding array sorting.... I have two arrays. The main one (where the key is the user id) : $user[31] = 'Tom' $user[43] = 'Jane' and another array with the order they should be displayed (where key is the order and value is the user id) : $or...

Php 2d array as C# 2d array/struct

I'm using MailChimp's API to subscribe email to a list. Function listsubscribe() is used for email subscription: public static listSubscribe(string apikey, string id, string email_address, array merge_vars, string email_type, boolean double_optin, boolean update_existing, boolean replace_interests, boolean send_welcome) I downloaded ...

Passing array into constructor to use on JList

I know the title sound confusing and thats because it is. its a bit long so try too stay with me. this is the layout i have my code designed variables constructor methods. im trying too fill a Jlist full on names. i want too get those names using a method. so here goes. in my variables i have my JList. its called contactNames; i also...

weird array syntax

I'm trying to figure how a function I've been given works -- or rather doesn't work. The problematic areas include array notation like this: $small[$end[$i]{0}] I think the idea is to append "0" to the value of $end[$i] and use that for the index of $small. But it doesn't work in PHP5.3. Is this a deprecated syntax and is it trying t...

Elegant way to get all objects of a specific type in an Objective-C array

I know I can do for (id obj in array) { if ([obj isKindOfClass:[Elephant class]]) [elephants addObject:obj]; } but I feel there must be a more elegant way of doing this. I've looked at filtering arrays but can't come up with a good predicate. Thoughts? ...

multi-dimension array value sorting in php

Another potentially interesting (or n00b, whatever comes first) question. I am building up an array with a set of database fields with information about table, actual field name and descriptive field name as a multi-dimensional array. Here is what it currently looks like: $Fields['User']['ID'] = "User ID"; $Fields['User']['FirstName'] ...

PHP, Building ID'd array from non-incremental ID'd CSV

Basically, here is my CSV File: 1,"Gold" 2,"English Version" 10,"Sword+0" 11,"Sword+1" 12,"Sword+2" And so on, you get the idea. There are other parts where the ID is not incremental, perhaps one is 2899 and then the next one is 3020. I'm trying to build an array from this with fgetcsv();. I can do it fine, but I've failed so far to m...

How to split a Ruby array into X parts

I have an array foo = %w(1 2 3 4 5 6 7 8 9 10) How can I split or "chunk" this into smaller arrays? class Array def chunk(size) # return array of arrays end end foo.chunk(3) # => [[1,2,3],[4,5,6],[7,8,9],[10]] ...

How to the values of an array to populate the keys of another array?

I have an array of field names. I would like to use those to populate the keys of another array, which will have empty values as default. Is there a single command I can do this with? ...

Scala Array constructor?

scala> val a = Array [Double] (10) a: Array[Double] = Array(10.0) scala> val a = new Array [Double] (10) a: Array[Double] = Array(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) Why these two expressions have different semantics? ...

Array not showing in Jlist but filled in console

Hey there. been a busy debugger today. ill give ths short version. ive made an array list that takes names from a database. then i put the contents of the arraylist into an array of strings. now i want too display the arrays contents in a JList. the weird thing is it was working earlier. and ive two methods. ones just a little practi...

Remove first element from $@ in bash

I'm writing a bash script that needs to loop over the arguments passed into the script. However, the first argument shouldn't be looped over, and instead needs to be checked before the loop. If I didn't have to remove that first element I could just do: for item in "$@" ; do #process item done I could modify the loop to check if i...

Flatten a PHP array

Say I have a form with these fields, and cannot rename them: <input type="text" name="foo[bar]" /> <input type="text" name="foo[baz]" /> <input type="text" name="foo[bat][faz]" /> When submitted, PHP turns this into an array: Array ( [foo] => Array ( [bar] => foo bar [baz] => foo baz [b...

Running an array of processes

I have the following array: procs=( 'one a b c' 'two d e f' 'three g h i' ) I try run these processes from a loop (using echo instead of eval so I can debug): for proc in ${procs[@]} do echo $proc done I get: one a b c two d e f three g h i I wanted: one a b c two d e f three g h i What went wrong? ...

Need Associated ID Added to a While Loop (php)

Been trying to get my head around while loops for the last few days but the code seems very inefficient for what Im trying to achieve. I'm assuming I'm overcomplicating this though nothing I've tried seems to work. Each topic in my forum can have related topic IDs stored in a seperate table. A post ID is also stored in this table, as th...

Declaring an array of linked list in C#

I got the compile error message "Array size cannot be specified in a variable declaration (try initializing with a 'new' expression)" when I tried to declare an array of linked lists. public LinkedList<LevelNode>[2] ExistingXMLList; Also, if I wanted to create a small array of strings, isn't the following the correct way? string [2] ...

Send multidimensional array to php with jQuery

hy, i have a little, big problem here :) after i upload some images i get a list with all the images. I have some jQuery function for rotate, duplicate, delete, shuffle images! when i select a image and hit delete i send a post to php with the alt="" value of the image,i identify the picture and edit. I want to make a save button, Inst...