arrays

Can Java store methods in arrays?

Well I wrote some code and all I was doing was for loops, but changing which method I called. I tried using a for loop so it'd be a bit neater (and out of curiosity to see if it could be done), but it doesn't compile when I do it this way, because it doesn't recognize an item in an array as a method, I think. This is what I have: String...

PHP | Remove element from array with reordering?

Hey Folks, how can I remove an element of an array, and reorder afterwards? <?php $c = array( 0=>12,1=>32 ); unset($c[0]); // will return sth. like array( 1=>32 ); ?> How can I do a "rearrange" like pointing the 1 to 0 after delete (automatically)? Thanks! ...

How to create nested lists in python?

I know you can create easily nested lists in python like this: [[1,2],[3,4]] But how to create a 3x3x3 matrix of zeroes? [[[0] * 3 for i in range(0, 3)] for j in range (0,3)] or [[[0]*3]*3]*3 Doesn't seem right. There is no way to create it just passing a list of dimensions to a method? Ex: CreateArray([3,3,3]) ...

C# byte[] comparison without bound checks

I am looking for performance efficient ways to compare two byte[] for equality. Sizes are above 1 MB, so the overhead for each array element should be minimized. I aim to beat the speeds of SequenceEqual or a hand-coded for-loop over every item, by avoiding the repetitive bound checks for both arrays. In the same way that Array.Copy co...

array_map show mysql_real_escape_string() expects parameter 1

when i use array_map('mysql_real_escape_string', $_POST); it display Warning: mysql_real_escape_string() expects parameter 1 to be string, array given in D:\xampp\htdocs\...\...\xyz.php on line 14 what is the reason after that? EDIT: and if i use array_walk_recursive($_POST, 'mysql_real_escape_string'); then it display W...

Translate a code using pointer, to Assembly in Pascal - Delphi

Hi all. I have this code below, and I want to translate it to ASM, to use in Delphi too. var FunctionAddressList: Array of Integer; type TFunction = function(parameter: Integer): Integer; cdecl; function Function(parameter: Integer): Integer; var ExternFunction: TFunction; begin ExternFunction := TFunction(FunctionAddress...

Making sure a PHP array has only sequential keys.

Is there any way to have an array with items like: $array[1]; $array[3]; $array[4]; Be turned into an array like this: $array[1]; $array[2]; $array[3]; So that the array has only sequential numeric keys? Thanks! -iMaster ...

Using string tokenizer to set create arrays out of a text file?

Hey. You may have recently seen a post by me looking for help, but I did it wrong before, so I am going to start fresh and begin at the basics. I am trying to read a text file that looks like this: FTFFFTTFFTFT 3054 FTFFFTTFFTFT 4674 FTFTFFTTTFTF ... etc What I need to do is put the first line into a String as the answer key...

How to recursively subtract from an array?

I'm pulling the url parameter and I'm trying to create a breadcrumb out of it. So, if I pull: $url = 'contact/jane/now'; and I do: $path = explode("/",$url); How can I put it in a loop so that it breaks each part into a path like this: <a href="/contact">contact</a> <a href="/contact/jane">jane</a> <a href="/contact/jane/now">now...

JavaScript: refactoring, avoiding array.push()

I've got a function in an object like this: arrayofElements: function(item) { var result = []; if (item.isA) { result.push(new Div('aClass', labels['A'])); } if (item.isC) { result.push(new Div('cClass', labels['C'])); } if (item.isD) { result.push(new Div('dClass', labels['D'])); ...

Insert array in ONE field in mysql

Hello .. I want to insert an array in ONE field in mysql database using PHP .. this is work fine : HTML : anotherField :<input type="text" name="anotherField" /> fax :<input type="text" name="f[]" /> email :<input type="text" name="f[]" /> phone :<input type="text" name="f[]" /> PHP (I use CodeIgniter frame) : <?php functi...

How to change orders of array in PHP?

$a = array(0=>'a',1=>'b',2=>'c', 3=>'d'); I want to change the order to be 3,2,0,1: $a = array(3=>'d',2=>'c',0=>'a', 1=>'b'); ...

how to reset an array index? actionscript3

I got a problem with processing an array in actionScript. I removed the last element of an array through array.pop(); After that I would like to put this removed display-object back to the beginning of the array. (array.unshift(object)) The object is now the first element of the array but it got still its old label (number of the last el...

PHP Get element with 5 highest occurrence in an array

Something similar to this: http://stackoverflow.com/questions/1053843/get-element-with-highest-occurrence-in-an-array Difference is I need more than 1 result, need 5 results altogether. So the 5 top highest occurence in a (large) array. Thanks! ...

Why is my array deleting the zeroes from a file I am reading?

Hey hey there. Well, I am attempting to read a text file that looks like this: FTFFFTTFFTFT 3054 FTFFFTTFFTFT 4674 FTFTFFTTTFTF ... etc And when I am reading it, everything compiles and works wonderfully, putting everything into arrays like this: studentID[0] = 3054 studentID[1] = 4674 ... etc studentAnswers[0] = FTFFFTTFFTFT stud...

Return Structure from Function (C)

I need to create a structure inside a function (dynamically with malloc) Then i need to be able to send it to my main, and use it there. I have no problems creating it, I simply need help sending it to my main, and I'm also unsure of how to access it once I get it there. struct retValue * fn() { struct retValue { int number; }; ...

populate multi-dimensional arrays.

hello, im just working on integrating a script into my own site and this script (being that is has a chat feature) has inbuilt smilies, my site also has smilies but the url of them is stored in the sites mysql db, pulling said files from the db into the script im integrating is easy, but the script uses a 2 dimensional array for the smil...

How to operate the elements of an array

I have to operate a 4 elements array, calculating the difference between the adjacent elements and creating a new array with the resulting differnece. The last element should be colindant with the first one. example: firstArray=[0,1,2,3]; secondArray = newArray(); The second array will be: secondArray[0]: 1-0 = 1 secondArray[1]: 2-1...

Creating an array from a constructor in C#

So I've been trying to figure out how to populate an array with an object I have created in C#. I found this code sample which explains a bit about what I need to do. for (int i = 0;i<empArray.Length;i++) { empArray[i] = new Employee(i+5); } But what happens if I pass more than one parameter into my construc...

database tree to multidimensional array

Hi, i have a simple database tree with parentid and i want to read the db and get an array like above Array ( Title: Category 1 Children => Array ( => Title: Category 1.1 => Title: Category 1.2 Children => Array ( ...