arrays

Uploading multiple files with PHP

This is my HTML markup: <p><input type="file" name="file[]" id="file" /></p> <p><input type="file" name="file[]" id="file" /></p> <p><input type="file" name="file[]" id="file" /></p> <p><input type="file" name="file[]" id="file" /></p> <p><input type="file" name="file[]" id="file" /></p> When I submit the form, the form is submitting ...

Arrays of unknown length in Visual Basic

I have a piece of code written in Visual Basic: Dim n As Double, i As Integer n = 4 Dim Ramp_length(1 To 4) As Double For i = 1 To n Ramp_length(i) = Cells(13 + i, 5) 'Cells(65 + i, 7) = Ramp_length(i)' Next i Is there a way I can reproduce the result without declaring the array with a "fixed" length? I eventually want the cod...

can you remove one array from another in javascript or jquery

i have a three arrays in javascript var array1 = new Array (1,2,3,4,5); var array2 = new Array ("a", "b", "c", "d", "e"); var array3 = new Array ("a", "c", "d"); and i basically want to: Create a new array with array2 minus items in array3. So it should result in var array4 = new Array {"b", "e"}; Create another array with the cor...

Adding a numerical value to a byte?

public void EncryptFile() { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|All files (*.*)|*.*"; dialog.InitialDirectory = @"C:\"; dialog.Title = "Please select an image file to encrypt."; if (dialog.ShowDialog() == ...

does javascript have an exists() or contains() function for an array

or do you just have to do a loop and check each element ? ...

Memory management with HEAP arrays

Hello everyone, If i create a heap array inside a loop, do i have to delete it at the end of each loop before i reinitialize it at the beginning of the loop again or will reinitializing the exact same thing again simply overwrite the old array and i can just skip the delete command? ...

Interview question: C program to sort a binary array in O(n)

I've comeup with the following program to do it, but it does not seem to work and goes into infinite loop. Its working is similar to quicksort. int main() { int arr[] = {1,1,0,1,0,0,0,1,0,1,0,1,0,1,0,1,0,1}; int N = 18; int *front, *last; front = arr; last = arr + N; while(front <= last) { while( (front < last) && (*front == 0...

Sorting array of objects by two criterias?

I have an array of objects that i want to sort by two keys. The objects lets say are of type Student and the properties that i'm intrested in for my sort are grade and name. Student { double grade; string name; ... } How can i sort the objects first by grade and then by name? so for example if i have the list: Tom 9.9 And...

Get average value from double[] between two indices

I have a double[] array holding many numbers. I have an algorithm that selects sections from within this array that fall under certain conditions (value greater than x, at least y values, etc.) Now I want to calculate the average value of all these values in my section. So, say my section is from index 20 to 40. Now I have 20 values. ...

initializing multi-dim string arrays

Stuck here trying to initialize an array (c#) using a loop. The number of rows will change depending. I need to get back two values that I am calculating earlier in the program startweek, and endweek. Lots of examples on building int arrays using loops but nothing I can find re dynamic strings and multi dim arrays. Thanks how do I set ...

Javascript array of object to array of string, simpler way?

I am so used to the syntactic sugar of C# (and not as used to javascript as I want to) that I find this very verbose. Is there any better way to do this? var justColumnNames = new Array(); for( i= 0; i< columnsInfo.length; i++) { justColumnNames[i] = columnsInfo[i].Name; } (BTW I have the Extjs available in the page, and I can...

Recommended type for a VERY large array(memory wise) in C#

I have a large array with around 20k objects in it. Each object has child objects in a big complicated tree structure with arrays in there too. Right now the app is developed using just a simple myObjectType[] myArray and it takes 13 seconds just to get the count of items in the array. Is there a better type or is there a better way ...

Remove array values in pgSQL

Is there a way to remove a value from an array in pgSQL? Or to be more precise, to pop the last value? Judging by this list the answer seems to be no. I can get the result I want with an additional index pointer, but it's a bit cumbersome. ...

what does compiler do with a[i] which a is array? And what if a is a pointer?

I was told by c-faq that compiler do different things to deal with a[i] while a is an array or a pointer. Here's an example from c-faq: char a[] = "hello"; char *p = "world"; Given the declarations above, when the compiler sees the expression a[3], it emits code to start at the location ``a'', move three past it, and fetch the ch...

PHP Sorting associative-array by other array

I need to sort an associative-array in the exact order of the content of another array. The Arrays are retrieve by 2 separate sql-requests (stated below). The requests could not be combined to only one request, so I have to sort the second array into the order of the first one. These are the arrays: #Array which contains the id's in ne...

Set rank of array at runtime

Hi, I was wondering what the simplest way would be to implement an array who's rank is specified at runtime. The example I am working on stores a array of boolean values for lattice points, and I want the user to be able to chose how many spatial dimensions the model uses at runtime. I've looked at the Array.newInstance() method: dim...

Resizing Arrays - Difference between two execution blocks?

I have a function which grows an array when trying to add an element if it is full. Which of the execution blocks is better or faster? I think my second block (commented out) may be wrong, because after doubling my array I then go back and point to the original. When creating arrays does the compiler look for a contiguous block in memo...

trying to send array through GET variable, when printed, var equals string of 'Array'

Whenever i build a URL i.e. cart.php?action=add&p[]=29&qty[]=3&p[]=5&qty[]=13 and try to grab the p variable and the qty variable, they = 'Array' var_dump = array(3) { ["action"]=> string(3) "add" ["p"]=> string(5) "Array" ["qty"]=> string(5) "Array" } i create half the url with php, and the other half is concatenated with ja...

help with array

What am i doing wrong here? The username string is less than 2 chars but it still dont set error[]? Register: $errors = array(); $username = "l"; validate_username($username); if (empty($errors)) { echo "nothing wrong here, inserting..."; } if (!empty($errors)) { foreach ($errors as $cur_error) $errors[] = '<li ...

Loop not looping fully on actioning on first iteration

I am doing a multiple upload using the Multiple_upload library in codeigniter, and form some my loop that creates thumbnails only fires on the first iteration it would seem here is my code function saveContentImages() { $this->load->model('categoryModel'); if($query = $this->categoryModel->getCategoryByContentId($this->input->po...