arrays

How do you Iterate a multidimesional array without knowing the number of dimensions and elements of the array being passed to you?

A SDK is returning me an array with multiple dimensions such as: int[,,] theArray = new int[2,8,12]; I need to visit each element in the array and return the value and the position of the value. I need to do this without knowing the number of dimensions and elements of the array being passed in. ...

array initialisation

Hi all, I'm quite certain that arrays of built in types are unitialized, whereas arrays of UDTs are default initialized. int foo[5]; // will contain junk Foo foo[5]; // will contain 5 Foo objects that are default initialized This occurs regardless of whether the array is allocated on the stack or heap. However, I'm finding it hard ...

can you return a string[] from ASMX to JQuery AJAX?

Here's my web method [WebMethod(EnableSession = true)] public string[] LoadArray() Here's my javascript $.ajax({ type: 'POST', url: '/services/Service.asmx/LoadArray', data: "{}", contentType: 'application/json; charset=utf-8', dataType: 'json', success: function(arr) { for ...

change value of a line in an array

I need to change the value of a line within an array to a given string, then implode and save the data. Im using the code below. row is the row of the table. target is the specific line in the array which i want to update. nfv is the new string i want to put into the array. <? $rowpre = $_GET['row']; $newfieldvalue = $_GET['nfv']; $row...

invalid argument when imploding in php

Im getting invalid argument error when running the following code. Im trying to change the value of a line in the $info array, then implode it, implode its parent array, and then save the whole shebang back to whence it came. $rowpre = $_GET['row']; $newfieldvalue = $_GET['nfv']; $row = --$rowpre; $data = file_get_contents("temp.php"); ...

Getting the Percentage of changes

How can i get the percentage of the changes which happened? Like 1. date 1343360810 objectId 1628 field 10 value 3 1. date 1242360811 objectId 1628 field 10 value 5 1. date 1243364812 objectId 1628 field 10 value 5 1. date 1240360814 objectId 1628 field 10 value 5 This would mean the v...

PHP5: Adding stuff into a multidimensional array given a location of any length?

// given following array: $data = array( 0=>array( "data"=>"object1", "col"=>array( 0=>array( "data"=>"object2", "col"=>array( 0=>array( "data"=>"object3", ), 1=>array( "data"=>"object4", ), ) ), 1=>array( "data"=...

open file with raw csv data, explode array and subarray, change line, and pack it back up and save, in PHP

My goal here is to open temp.php, explode by ### (line terminator), then by %% (field terminator). Change a specific field, on a specific line, then implode everything back together and save it. There are a couple variables at play here: row = the target row number target = the target field/column number nfv = the info that i want to p...

Why must I assign the result of PHP's end() array function to a variable to operate on the result?

I've tried to delete the possibly empty last entry of an array as follows but I get the error: "Can't use function return value in write context": if (empty(end($crontabEntryList))) { array_pop($crontabEntryList); } If I first assign end's return value to a variable (as at the bottom) I am able to delete that last entry if emp...

arrays / pointers (C)

in C is: *(array) equivalent to array[0]? Therefore is *(array+2) equivalent to array[2]? ...

Pick a random number from a set of numbers

I have an array of integers like these; dim x as integer()={10,9,4,7,6,8,3}. Now I want to pick a random number from it,how can I do this in visual basic?Thanks in advance... ...

Using variables in an array passed to a def - Rails

I'm using the Google charts API to generate a pie chart in my Rails application. However, I'm having a problem passing local variables to the def in the helper. The def takes a 2D array of [label, value] pairs. It doesn't like it when I try to pass a local variable in as the value. These are calculated ahead of time and are in currenc...

Jquery functions in array

Hello evryone. I have a litle problem with my Javascript functions. It might be a litle deep into my code as well but im prety sure someone on Stackoverflow know the awnser! Ok first i have a PHP session that i use to save my image id's Then i have a page that shows 5 images at a time with a JQuery Click fonction to browse my images ...

Code Challenge: 2D Array Search

Ok this one is like my previous array searching challenge but with a twist. You must build a function to search one 2d array (or suitable equivalent in your language) of 32-bit integers for another, and return the X and Y index that the second array exists within the first. If the second array does not completely and contiguously exist ...

Removing loop MC inside array

How to remove the movieclip by removeChild and later on clean the array for refresh purposes? for (var t:int=0; t<8; t++) { circlesArray[2][t].removeChild(MovieClip) } ...

What is the syntax to pass an array of Sprites into the Tweener Class in Actionscript 3?

This works: Tweener.addTween( [ _fee, _fye, _fum ] , { alpna:1, time:10 }); But this does not: var _myArray:Array = new Array( [ _fee, _fye, _fum ] ); Tweener.addTween( _myArray , { alpna:1, time:10 }); How can I pass the an array straight into the tweener? ...

How do I have a more advanced array?

Hi there, Basically I currently put a bunch of values into an array like so: $flavors = array('Original','Cherry','Chocolate','Raspberry','Mango'); and from this I might execute a foreach like so: foreach($flavors as $flav) { echo doSomething($flav); } This all works a treat, until I get to the next stage of my learning whi...

PHP find element key

i have this array Array ( [0] => a [1] => b [2] => c [3] => d ) how can i get an element's key?(for example a=0,c=2) ...

Class Vs Pure Array Representation

We need to represent huge numbers in our application. We're doing this using integer arrays. The final production should be maxed for performance. We were thinking about encapsulating our array in a class so we could add properties to be related to the array such as isNegative, numberBase and alike. We're afraid that using classes, howe...

Merging multiple associative arrays in PHP

I'm not quite sure how to do this. Let's say I have 2 associative arrays $arr1 = array('a' => "1", 'b' => "2", 'c' => "3"); $arr2 = array('a' => "9", 'b' => "8", 'c' => "7"); How could I possibly produce an "add-up" array as below $arr1 = array( array('a', "1", "9"), array('b', "2", "8"), array('c', "3", "7") ); I'm not sure...