arrays

Performing an action when finding same values in two PHP arrays

Hello guys, I have two associative arrays in PHP that are defined as following: $this_week[] = array( "top_song_id" => $row["view_song_id"], "top_place" => $i, "top_move" => "0", "top_last" => $i, "top_peak" => $i, "top_rating" => get_song_rating_by_id($row["view_song_id"]), "top...

Is there a simple way to duplicate a multi-dimensional array in Ruby?

I have a 2-dimensional array in Ruby that I want to produce a working duplicate of. Obviously I can't do this; array=[[3,4],[5,9],[10,2],[11,3]] temp_array=array as any modifications I make to temp_array will also be made to array, as I have merely copied the object identifier. I thought I would be able to get around this by simply us...

Does JavaScript populate empty array items?

I am coding a lot of annual data in JavaScript, and I was considering adding it to arrays, using the year as the array index and putting the data into the array. However, Firebug seems to be indicating that JavaScript handles this by populating two thousand odd entries in the array with "undefined." With hundreds of such arrays kicking a...

Is it good practice to initialize array in C/C++?

I recently encountered a case where I need to compare two files (golden and expected) for verification of test results and even though the data written to both the files were same, the files does not match. On further investigation, I found that there is a structure which contains some integers and a char array of 64 bytes, and not all...

How do I remove the last comma from my string and replace it with a period in Javascript?

CSS: .dynamicDiv { width:200px; border:solid 1px #c0c0c0; background-color:#e1e1e1; font-size:11px; font-family:verdana; color:#000; padding:5px; } Javascript: //create array var myNames=new Array(); //var nameString=document.getElementById(myNames.toString()) function addToDiv() ...

Strange {} Syntax

private final String[] okFileExtensions = new String[] {"csv"}; Would someone please explain why {} is written after a String array decleration? Thanks. ...

System.Array GetLength and Length

How do you use the Array.GetLength function in C#? What is the difference between the Length property and the GetLength function? ...

default array values

Is there a way to assign a default values to arrays in javascript? ex: an array with 24 slots that defaults to 0 ...

Property based searches in Javascript

While looking for the best way to search an array of objects in Javascript (there doesn't seem to be a iterate + compare function for that) I came across this post which seems like are really elegant way of doing this. However I have some questions: Javascript doesn't have associative arrays. These seems like one. What gives? This see...

Loop through an Array of links and dynamically load the contents of each after a set interval

Using jQuery I would like to loop through an array of links and load the contents of each link into a DIV after a set interval. For example, if I have my parent page "parent.html" and an array of links - "test1.html, test2.html and test3.html" I would like to initially load test1.html into a div within parent.html and then after a set in...

Actionscript 3: Check an array for a match

If you have an array with six numbers, say: public var check:Array = new Array[10,12,5,11,9,4]; or public var check:Array = new Array[10,10,5,11,9,4]; How do you check for a match (of a pair?) ...

Objective C /iPhone : Is it possible to re initialize an NSArray?

I read that non mutable data types can't be modified once created.(eg NSString or NSArray). But can they be re-initialized to point to a different set of objects? If so, do I use release to free any alloc from first time round in between uses? eg: myArray declared as NSArray *myArray in interface, and as nonatomic/retain property.myA...

Dealing with char ** argv

How do I assign a sequence of character strings to a char ** argv variable in a program? Its a command line argument. I'm currently trying to convert an .exe app to a dll. For example: { "string1", "string2", "string3" } --- > char ** argv variable My problem is somehow realted to this: http://stackoverflow.com/questions/1015944/ho...

PHP array_merge_recursive with numeric keys

So I'm suppose to build a multidimensional array dynamically from a text file, and everything works perfectly except that the numeric keys are screwing me over... The text file looks something like this: a=1 b.c=2 b.d.0.e=3 b.d.0.f=4 b.d.1.e=5 b.d.1.f=6 As the array_merge_recursive doesn't work with numeric keys, the output is like...

Can't break out of nested for loops

I have the following function but despite using the break statement, it doesn't seem to be stopping after it finds a match in the array: private function CheckMatch() { // _playersList is the Array that is being looped through to find a match var i:int; var j:int; for (i= 0; i < _playersList.length...

php - recreate array from flat to multidimensional?

I am trying to take a flat array and recreate it so that it's multidimensional. I've been looking into array_combine and array_merge, but I'm not sure that either of those will give me what I'm hoping for... The array, in it's current form (and this is just a simplified example): Array ( [0] => stdClass Object ( ...

Getting the dimensions of multidimensional arrays in C#

Suppose that my function gets a two dimensional array as input and its dimensions are unknown. How can I figure them out using reflection? ...

PHP: How do I search an array for all entries of a specific key and return value?

I've got a multidimentional array such as: $array = array( array('test'=>23, 'one'=>'etc' , 'blah'=>'blah'), array('test'=>123, 'one'=>'etc' , 'blah'=>'blah'), array('test'=>33, 'one'=>'etc' , 'blah'=>'blah'), ); How to I search the array for all the keys 'test' and get the value? I wish to add all of the values of 'test' found ...

AS3 Attaching event listeners to elements of an array

Hello I am having trouble attaching eventListeners to the elements within my array, any help/suggestions would be great.. thanks for reading var urls:Array=["../showcaseThumbnails/1.jpg", "../showcaseThumbnails/2.jpg", "../showcaseThumbnails/3.jpg", "../showcaseThumbnails/4.jpg", "../showcaseThumbnails/5.jpg", "../showcaseThumbnails...

PHP: high depth array, how do return current key name?

I have a huge array from a json_decode result (assoc set to true) and have the following code to check if (one of the arrays within, a random serial) has the key 'set_true' $out = ""; foreach ($array as $sub) { //$out[] = $sub['set_true']; if (in_array($sub['set_true'], $sub) && $sub['set_true'] == '1' ) { $out[] = 'User: ' . $...