arrays

PHP search array and add content on position where id's are equal

Hi erveryone, I have 2 assoc. Arrays which have the same structure, but only one ID is identical. I need to add content to the MainArray from the IncludeArray everytime the specific ID is identical. Here are a sample of the Arrays (MainArray could hold up to 100 or more items, the sample contains only a portion of the real content): $...

SQL result to PHP multidimensional array

Hi, I'm retrieving some hierarchical data from an Oracle database using the "connect by" function. Then I populate a PHP array with the result of my query looking like: while ($row_branches = oci_fetch_array($query_tree)) { $tree[] = array( 'id' => $row_branches['ID'] , 'parent' => $row_branche['PARENT'] , 'data' => htm...

R array manipulation

In python lists can be sliced like this x[4:-1] to get from the fourth to the last element. In R something similar can be accomplished for vectors with x[4:length(x)] and for multidimensional arrays with something like x[,,,,4:dim(x)[5],,,]. Is this more elegant syntax for array slicing for a particular dimension from an element in the...

C++ container/array/tuple consistent access interface

hello Is there, perhaps in boost, consistent element access semantics which works across containers? something along the lines of: element_of(std_pair).get<1>(); element_of(boost_tuple).get<0>(); element_of(pod_array).get<2>(); in principle i can write myself, but I would rather not reinvent the wheel.thanks ...

iPhone SDK synthesizing BOOL Array

Hello, I get a compiler error when trying to synthesize a bool array like this: // .h #import <UIKit/UIKit.h> @interface SomeViewController : UIViewController { BOOL boolArray[100]; } @property (nonatomic) BOOL boolArray; @end //m #import "SomeViewController" @implementation SomeViewController @synthesize boolArray; @e...

String contains any items in an array (case insensitive)

How can i check if a $string contains any of the items expressed in an array? $string = 'My nAmE is Tom.'; $array = array("name","tom"); if(contains($string,$array)) { // do something to say it contains } Any ideas? ...

how to convert a hash into an array with particular order? (ruby)

I have a hash of hashes (@post) and I want to save it into csv. Strange for me is that my approach works for the header but not for the rows. If I display the rows using csv << (@post_csv_order.each {|element| puts single_post[element]}) I can see the right strings on the screen but the csv files contains values of the hash key not t...

How can I access the contents of this PHP array?

Below are the files in PHP that I am trying to include a file that holds an array into my class and then access the array. if I run print_r() on it I get results but if I try to access the array item individually I get nothing, can anyone help me please? <?php // config.class.php /* example usages $config = Config::getInstance(PATH_TO_...

Dynamicly added movieclip from library tween problem

Hi, I'm having trouble with tweening (with TweenMax) movieclips added dynamically in a for loop. The targeting works fine but the tweens are just not happening. :( My second problem is that I need to randomize my array but I dont know how. Anyway here is my code, and thank you for your help. :D import gs.*; import gs.easing.*; stop(...

Ruby: catching access to variable inside class

I have a class, which de-constructs incoming string into a nested array cascade. For example for an input abcde it will produce a [[[[a,b],c],d],e] array. Just now, if I access to set any top level value of cascade, the []=(index, value) method of my class will be invoked. But I also need to catch the access to the nested array within c...

Lua's hybrid array and hash table; does it exist anywhere else?

Lua's implementation of tables keep its elements in two parts: an array part and a hash part. Does such a thing exist in any other languages? Take a look at section 4, Tables, in The Implementation of Lua 5.0. Lua 5.1 Source Code - table.c ...

Explanation of [].slice.call in javascript?

I stumbled onto this neat shortcut for converting a DOM NodeList into a regular array, but I must admit, I don't completely understand how it works: [].slice.call(document.querySelectorAll('a'), 0) So it starts with an empty array [], then slice is used to convert the result of call to a new array yeah? The bit I don't understand is ...

Create managed .NET array without initializing to all zeros

Take the following C# method: static double[] AddArrays(double[] left, double[] right) { if (left.Length != right.Length) { throw new ArgumentException("Arrays to add are not the same length"); } double[] result = new double[left.Length]; for (int i = 0; i < left.Length; i++) { result[i] = left[i] + righ...

going through an array of strings and printing one and then calling the method and printing the next one

I'm trying to go through an array of strings and print one index at a time, but when I tried running the program all I get is a 0 or 1. I'm not really sure how to fix this. Below is what I have so far. So when I call on the method I've created for this, I would like to call "Turnip" and when I call it again I get "Little Old Lady". I'm ...

PHP Array Operation

$arr = array('id1','id2',...); How to get #id1,#id2,.. from the above array? ...

hash assignment when (key => value) are stored in an array? (ruby)

I have hash (@post) of hashes where I want to keep the order of the hash's keys in the array (@post_csv_order) and also want to keep the relationship key => value in the array. I don't know the final number of both @post hashes and key => value elements in the array. I don't know how to assign the hash in a loop for all elements in th...

What's the technical reason why class constants can't be arrays in PHP?

Anybody knows the technical reason why this constraint is placed on PHP classes (at least in v5.1x)? ...

how to update a cell in DataGrid which is binded with string[][] array

I have a DataGrid and a string[][] dataSource array as a source data for this DataGrid. I use following code to set binding: dataGrid.ItemsSource = dataSource; for (int i = 0; i < columns; i++) { dataGrid.Columns.Add(new DataGridTextColumn { Binding = new Binding(string.Format("[{0}]", i)) }...

C++ strcpy non-constant expression as array bound

Hi I turned back to C++ after a long time in C#, PHP and other stuff and I found something strange: temp.name = new char[strlen(name) + strlen(r.name) + 1]; this compiles temp.name = (char *)malloc(sizeof(char[strlen(name) + strlen(r.name) + 1])); this doesn't (temp.name is a char *) The compiler error is error C2540: n...

Array Elements Overwritten with Last in C

I'm trying to create a program which takes in a set number of strings (the user is asked to put in the number of strings they will enter), once it has these strings, they are placed in an array, using dynamic memory. The ouput would be something like this: # of Strings: 3 Cat Dog Elephant Cat Dog Elephant Heres a snippet of my code...