Most voted "array" questions
An array (array, vector, or matrix) is an ordered data structure representing a collection of elements (values or variables), each identified by one or multiple indices.
Learn more…3,046 questions
Sort by count of
-
6
votes1
answer900
viewsMore elegant ways to invert integers, arrays and strings in Python
Hail! I’ve been looking for elegant ways to do string inversion, arrays and integers in Python. What do you think of my codes below and what suggest to improve them? They work... Thank you! frase =…
-
6
votes3
answers16826
viewsHow to create an array within another array with jQuery
I’m trying to create a array in jQuery using the . push() function where each element should contain another array within it. The structure I need to create is this: array( 'elemento1' => array(…
-
6
votes1
answer546
viewsPHP array of objects without access to get methods
I’m trying to access the getters which refer to an object, but this object is in an array, and by no means can I access them. Follow the DAO class (where the mess is taking place and I’m taking the…
-
6
votes1
answer270
viewsVisual Basic Excel - Delete an array name
I’m here with some problems, I never touched Visual Basic and I was wondering if it would help me to make a list I have in Excel faster (Through Visual Basic Excel). It’s very simple, I just want to…
-
6
votes1
answer609
viewsAccess values within an array from the index
I have a variable x with the following content inside: x = [ { id: '1', name: 'name, } ] And I thought to access the id were x.id, however, it is not so. How to access?…
-
6
votes1
answer1150
viewsRecursive analysis of a vector
QUESTION: Write a function recursive that analyzes the elements of a vector and returns one of the following codes: 0 Disordered elements 1 Elements sorted in ascending order 2 Constant elements 3…
-
6
votes2
answers1244
views -
6
votes5
answers1057
viewsProblem with in_array()
I have a problem with the in_array function. I made a var_dump() in the array I want to search for: array(2) { ["28c8edde3d61a0411511d3b1866f0636"]=> array(8) { ["id"]=> string(32)…
-
6
votes3
answers3711
viewsHow to shuffle characters from a Java string randomly?
I’m developing a password generator program. In it the user can set the percentage of numbers, letters and special characters that he wants to have in his password, as well as the size of his…
-
6
votes2
answers635
viewsHow to know the key of the 3 greatest results array?
have this array $qtd = array( 'acao' => $acao, 'aventura' => $aventura, 'comedia' => $comedia, 'drama' => $drama, 'faroeste' => $faroeste, 'ficcao' => $ficcao, 'suspense' =>…
-
6
votes1
answer282
viewsIs there any way to assign values to a vector faster?
For example, I have the statement of the following vector: float vet[3] = {1, 1, 1}; It would be possible to change all values of the same at once, without having to change one by one element or…
-
6
votes1
answer2200
viewsWhat is the maximum amount an array can support in PHP?
In PHP I often work a lot with frameworks. Generally, they bring the results of the query to a database in a array. In some cases, when the number of data from a table or a relationship reaches a…
-
6
votes2
answers602
viewsDifference in C/C++ array declarations
What is the difference and impact that each of these 3 vector statements bring to my code? int n; cin >> n; int* arr = new int[n]; int n; cin >> n; int arr[n]; int n; cin >> n;…
-
6
votes3
answers878
viewssort multidimensional array php
I have the following array returned from a webservice (in the image I identify what I want, below the text for copy): Array ( [DataTable] => Array ( [ID] => STOCK [Line] => Array ( [0]…
-
6
votes2
answers142
views -
6
votes1
answer2344
viewsMake a generic vector in Java
How to create a dynamic vector in Java with generic programming? This vector must have initial size 4 and be increased in size as new elements need to be inserted. The class must have: Constructor.…
-
6
votes2
answers140
viewsIs Array a C pointer?
I am reading a book about C pointers, but as I am new to such a language, still for me the concept of pointers is a bit complex, and when reading the following definition, I came to the question…
-
6
votes1
answer233
viewsDefine id of the php array()
I have the following array() Array ( [camposdb] => Array ( [51] => Array ( [0] => cpf_cnpj [1] => nome_razaosocial [2] => cod_cliente [3] => cod_contrato [4] => mensagem [5]…
-
6
votes2
answers3586
viewsHow to initialize an array in Kotlin?
I need to initialize an array in Kotlin more do not know how to do, in Java I did so: int numeros[] = new int[] {0,1,3,4,5,6,7,8,9};
-
6
votes2
answers146
viewsPointer changes address when exiting function
When performing a dynamic allocation of a vector or matrix in C, the pointer for that allocation changes address when leaving the function, before it was pointing to the initial address of the…
-
6
votes3
answers3023
viewsForeach Array incrementing another array
with a doubt in performing a foreach and incrementing another helper to perform an Insert in the bank, see only: When I send a form via post I have the following array as a result: array (size=2)…
-
6
votes2
answers119
viewsWhat’s going on in my C program?
I just have to add the lines but the values don’t make sense: Here the code: #include <stdio.h> #include <stdlib.h> int main (){ int matriz[6][6],i,h,somalinha[6]; for(i=0;i<=4;i++){…
-
6
votes4
answers130
viewsHow to format this array?
I have the following array: $dados = array( '0' => array( 'id_assinante' => $id, 'nome' => 'Aluguel' ), '1' => array( 'id_assinante' => $id, 'nome' => 'Água' ), '2' => array(…
-
6
votes1
answer708
viewsIn R, when does a vector become "Too long"?
When trying to create an infinite vector (1:Inf) I received the following message: Error in 1:Inf : result would be Too long a vector However, when the vector does not know in memory the message is…
-
6
votes4
answers1049
viewsString list + . Split()
The command string.Split() separates a string in a array of the kind string[]. How to use the string.Split() to separate strings in a list List < string>?…
-
6
votes2
answers796
viewsHow to separate a string by commas, except when you have a space later
I have a string and I need to separate it into one array. However, the separator character needs to be the comma (,), but if you have a space right after (", ") she is preserved in separation. I’m…
-
6
votes2
answers3248
viewsCapture repeated elements from a Javascript array
I need to remove the repeated values of a vector and play these repeated values in another vector, I found this code that removes the repeated values, but I do not know how to capture them, and I am…
-
6
votes4
answers5283
viewsSeparate an array into groups?
I have the code below answered by a question similar to this but I would like to upgrade, this is the current function: function separar(base, maximo) { var resultado = [[]]; var grupo = 0; for (var…
-
6
votes5
answers96
viewsMatrix with out-of-range index returning correct values
I was trying to create a matrix using while and realized that the program displays all the elements correctly if I just increment the value of j (column) up to 8. The program was not supposed to…
-
6
votes5
answers2427
viewsGet clicked element position
I have a list of entries and one of the attributes of that item is a delete button. By clicking the button I want to know the position of the line clicked inside the list. When knowing the position…
-
6
votes1
answer219
viewsError when adding value in array, repeated values
I have two arrays, A and B. I created 3 functions in which I take a value from the beginning of array A and array B, remove the values, compare the values and if the value of A is greater than that…
-
6
votes2
answers198
viewsstrcpy is merging numeric format with other chars
I don’t know if I made myself clear in the title, but when using strcpy() to copy a char* to another when I put a format like this "teste" it works normally, but when I put a string 3 letter format…
-
6
votes3
answers128
viewsMap with dynamic array and property
I’m trying to create a function map, whose array and property to be returned are dynamic, that is, can be passed as a function parameter. Let’s take the array below as a use case. const students = […
-
6
votes2
answers273
viewsWhy does pointing to the same memory address change an object?
If I run the following code: let a = [1, 2, 3] let b = a In this case, the variable 'a' and 'b' are pointing to the same memory address, consequently, everything I change to 'a' will theoretically…
-
6
votes3
answers90
viewsGroup array of emails by domain of each email in Javascript
I have an array of emails: emails = [ "[email protected]", "[email protected]", "[email protected]", "[email protected]" ] I am using regular expressions to parse domains, and my intention is to…
-
6
votes1
answer107
viewsHow does the use of "Set" to remove repeated values from an array in Javascript work?
Is it known almost general which, in Javascript, can be used this trick with Set and Operator spread for remove values duplicates of an array: const arr = [1, 1, 1, 2, 2, 3]; const deduped = [...new…
-
6
votes3
answers153
viewsWhat is the way to check and react to a change of state of an array using pure Javascript?
I’m studying about the pattern Observer where in an example done in Java it was demonstrated that an X class any called a specific method Y and this called methods updateof the observers, that is to…
-
5
votes2
answers353
viewsRemove matrix input by its value
To remove an input from an array, we can use the function unset(): <?php $arr = array(1, 2); unset($arr[0]); var_dump($arr); /* Resultado: array(1) { [1]=> int(2) } */ ?> Question How…
-
5
votes2
answers2746
viewsHow to make the jQuery toggle function in pure javascript?
I found out a little while ago and found very interesting toggle function using functions: $('body').toggle( function(){ alert('A') }, function(){ alert('B') } ); (In the example I put only 2…
-
5
votes2
answers5665
viewsCheck duplicate values in the array
My question is this:: I have the following array: $array = array(10, 30, 10, 40, 40); I would like to know if there is a simple way to display the message: "there are duplicate values" or "there are…
-
5
votes1
answer915
viewsDifficulties with binarySearch Class Arrays method
I created two arrays one of integers and the other of Strings(objects), but when I used the binarySearch method to know the position of the elements, the return of the positions of the Strings array…
-
5
votes2
answers1589
viewsGenerate single color for each result
then. i have a system of comments anonymously in a project of mine that in place of the avatar it puts the abbreviation of the person’s name, for example: Vinicius Eduardo -> VE and I want to…
-
5
votes1
answer3064
viewsDifference between null and clear on an Arraylist
What’s the difference between: arrayList.clear(); and arrayList = null; The two do not destroy all elements of Arraylist?
-
5
votes1
answer754
viewsWhat makes the for and what makes the brackets in an array?
I asked for help on some forums in an old game programmed in java, I understood the logic, but did not know how to apply it (which commands to use, and how to use), and I saw the use of Arrays.…
-
5
votes2
answers426
viewsPHP: elements with and without explicit keys in the same array
I’m trying to figure out a better or cleaner way to do something like this in PHP: // Isto será passado como argumento de uma função... $params = array('Nome', 'Idade', 'Mail' =>…
-
5
votes2
answers295
viewsWhy did a dynamic array work without the use of malloc()?
Follow the code passage below: int main(void) { int tam, vet[tam]; printf("\ndigite tam: "); scanf("%d", &tam); return 0; } I didn’t know this worked, because I’m typing the vector size at…
-
5
votes1
answer853
viewsMount array with txt data
I’m trying to find a way to assemble a table with the data of a txt, but I don’t know how to separate the values in the array, since they are separated by several spaces, but are identified by…
-
5
votes2
answers5775
viewsDynamic array in Javascript
I’m trying to generate a array made up of others arrays dynamically. For example: check = function (title, filter) { if (checked.indexOf(title) !== -1) { checked[title].push(filter); } else {…
-
5
votes3
answers1816
viewsFind sum of values in array
I need to develop an algorithm that finds a specific value of the sum of some elements of an array. Ex: I have an array with 50 different values and have a given value "X". I know that the sum of…
-
5
votes3
answers10914
viewsHow to remove the first element from a list in python?
I have the following code: On the command line > teste.py primeiro segundo In the script teste.py: import sys print(sys.argv) And I have the following return: ['c:\\teste.py', 'primeiro',…