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
-
4
votes1
answer158
viewsFormat values from one array into another
I have a CSV that returns me the following array: Array ( [0] => Array ( [0] => ANO [1] => Sciences [2] => Mechanics [3] => Telecom ) [1] => Array ( [0] => 2001 [1] => 226…
-
4
votes3
answers1067
viewsIndex or key in Javascript object
I have this situation: const movies = { 1: { id: 1, name: 'Planet Earth', }, 2: { id: 2, name: 'Selma', }, 3: { id: 3, name: 'Million Dollar Baby', }, What would these numbers be 1, 2 and 3 with two…
-
4
votes1
answer45
viewsstacked arrays
I gave a search through the internet and did not find answer for this my problem. Imagine that you have arrays stacked. For example: var array = [[[1, 2], [3, 4]], [[[5, 6], [7, 8]], [9, 10]]]; What…
-
4
votes2
answers186
viewsHow to convert Two-dimensional array to a Single array?
I have the following definition of Two-dimensional Array: int[,] arrayBidimensional = new int[3, 3] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; The above variable does not have a method .ToArray()…
-
4
votes1
answer1092
viewsDownload Javascript Array on a Combobox
I would like help in this small problem, I have to do a combobox shows 5 states being loaded by an array in javascript, my code is like this. HTML <select > <option…
-
4
votes1
answer101
viewsPass by reference printing garbage in the vector
Guys, I made a simple code, but I have a problem. I made a function "increase" to increase the size of a vector; the function receives the vector and passes the values of that vector to an auxiliary…
-
4
votes5
answers3692
viewscreate "contain" function that says if an array contains a certain element and returns true
I tried several ways with the indexOf (is a requirement of the issue use), but I’m having a lot of difficulty because I’m learning everything over the internet. The code I’m trying to use does the…
-
4
votes1
answer147
viewsCreate vectors of new types in Julia
I can’t create vectors of new types in Juulia, they don’t work. The example program is this: # Meu tipo customizado struct Job id::Int64 order::Int64 time::Float64 end #Aqui eu crio o vetor v =…
-
4
votes2
answers81
viewsFunction that returns an array of strings that are in all arrays
Talk people, all good? My doubt is simple, but the solution may not be so simple. The truth is that I am doing a job in JS and soon I will need to solve a problem that will make me spend a few hours…
-
4
votes3
answers7927
viewsDoubt about Struct and Pointer for Struct
I’m having doubts in my code about structs and pointers for structs, the doubts are as follows: 1) Because I don’t need to put (->) before speed, for example ( p->attributes->speed) in…
-
4
votes4
answers806
viewsAssignment of Java Arrays
I have two String Arrays and I have to compare them. After the comparison I must assign the repeated values in another Array. My problem is that I wish to assign only the Strings repeated without…
-
4
votes1
answer838
viewsForeach within Foreach PHP
I have the following code: $row = $twitterusers->selectUserAll(); foreach ($row as $fetch) { $users[] = $fetch; } var_dump($users); It takes all users from the table, but when using the var_dump…
-
4
votes3
answers1553
viewsReturn the index of the largest element in an array
I’m trying to return the higher index of the vector, I made the following code but returns undefined in function: let array = [2, 3, 6, 7, 10, 1]; function retornaMaiorIndice(){ for (let i = 0; i…
-
4
votes2
answers481
viewsPush() does not work in Vuejs?
I need to push() the data of Vuejs and make it add another object in the object array it has there. But when I click on the button I programmed for you to push() it just doesn’t. Follows code:…
-
4
votes1
answer40
viewsHow to make a Sort of a converted Nodelist to array?
I am trying to sort the array by the style property order. This is my attempt: var interval = setInterval(() => { var letterDivs = gameBox.getElementsByClassName("wordBox")[0].childNodes;…
-
4
votes2
answers129
viewsHow to choose a random array element in Javascript?
I already know how shuffle an array, but how do I choose a random element of arrays? let arr = ['a', 'b', 'c']; How do I choose any element of arr?…
-
4
votes1
answer90
views -
4
votes2
answers373
viewsConcatenate variable into array
I have to requisition one json for a api, but I have to redeem data from a form to complement this json, the problem is that when rescuing the data into a variable I cannot put it in the correct way…
-
4
votes5
answers1186
viewsHow to use the reduce (reduce) operation on objects?
In Javascript, when I need to do a reduction operation, I use the method Array.reduce. Thus: var valores = [1, 2, 3, 4, 5, 1000]; var resultado = valores.reduce(function (soma, atual) { return soma…
-
4
votes2
answers59
viewsFetch values in an object
I’m trying to access properties of an object, a dictionary. However the references are in format {String} and its concatenation through a point (.) and I’m using split() to break this {String} in a…
-
4
votes1
answer2980
viewsC# Console Application. Read Json File
I have a Json file and it always gives error when I try to read it. I believe because it is an array within another array and I cannot read. Json: { "map": [ ["S", "S", "S", "S"], ["S", "S", "C",…
-
4
votes2
answers897
viewsSeparate equal values in an array
Well I have the following array: $produtos2[] = array( "cod" => (int) 768, "nome" => "LOGITECH M535", "GRUPO" => "MOUSE" ); $produtos2[] = array( "cod" => (int) 2334, "nome" =>…
-
4
votes1
answer888
viewsConverting String to Arraylist
I am receiving in my java code a variable with the following value String arquivo = "CNPJ;INSCRICAOESTADUAL;COD_IBGE;DT_OPE;VLR_CARTAO_CRED;VLR_CARTAO_DEB 35083840049;0;4312476;13/01/2018;0.00;66.00…
-
4
votes2
answers522
viewsDynamic allocation of vectors
Follows the statement: Make a program that reads keyboard numbers and store them on one dynamically allocated array. The user will type in a sequence of numbers, no quantity limit. The numbers will…
-
4
votes3
answers82
viewsSequenced array within dropdown
Guys, I have a code that prints the arrays if I set the values, but I would like that sequence to be automatic. Let me show you so it’s clear. <?php $busca_produtos = new Produto; $produto =…
-
4
votes3
answers1169
viewsVector sum problem in C
Vector sum problem, I’m trying to put the sum of the vectors directly into loop, but he is not doing the sum of all but duplicating the last vector, I tested the same code in Portugol and it worked…
-
4
votes1
answer1930
views -
4
votes1
answer12340
viewsHow to clear/remove ALL elements of the javascript array?
I’m creating a javascript calculator for better learning and am having difficulty in remover todos os elementos do array. Know when you click the button "AC" calculator and it removes everything?…
-
4
votes1
answer76
viewsArray Ordering with Value Exchange
Good Afternoon! I have assembled an array that receives 9 records from a single variable and the values are displayed on the user screen. However, when trying to put this matrix in ascending order,…
-
4
votes1
answer117
viewsResize a vector in Matlab
Good afternoon. Here’s the following, I used the following function to create an empty array that later stores certain values requested from the user: fragil = zeros(1, 10); %criaçao do vetor idF =…
-
4
votes1
answer2524
viewsHow to remove an object from an object array within another object array, in javascript?
Hello, I need to return the objs array by eliminating the objects that have the req key === "test" inside the c object array. Thanks for your help! const objs = [ { a: "a", b: 1, c: [ { send:…
-
4
votes1
answer223
viewsPHP in_array()
My array $tx is: Array ( [tax_val] => Air bag ) testing: echo (in_array('Air bag',$tx['tax_val'])?'Existe':'Não existe'); Returns: Warning: in_array() expects Parameter 2 to be array, string…
-
4
votes2
answers105
viewsHow do I treat a jQuery array (remove duplicates and prevent an item from appearing in 2 arrays)?
I have 2 arrays (like and notlike) and as I give like or notlike, it adds the item in the array, currently it is like this: //DEFINE ARRAYS like = new Array(); notlike = new Array(); //SE CLICA NO…
-
4
votes1
answer142
viewsProblem with System.Indexoutofrangeexception in C#
I need to create a class Marca and a Modelo, both related to cars, where model will know your brand and brand should know your models. Model Class: namespace AssocMatrizes.Model { class Modelo {…
-
4
votes3
answers1637
viewsHow to iterate with two-dimensional array?
Hello, I am making a library to help in the creation of games and for that I would like to know how to iterate in two-dimensional arrays, I know that the array for one-dimensional is just to do:…
-
4
votes2
answers435
viewsHow to join repeated values of an object array, only in an object of the same array?
I have the following exit: [ { rank: 1, item: { userName: 'Rafaela', score: 600 } }, { rank: 2, item: { userName: 'Carla', score: 410 } }, { rank: 2, item: { userName: 'Yuri', score: 410 } }, {…
-
4
votes3
answers1189
viewsCheck if a string exists in an array
Write a function that checks whether the past skill vector has the Javascript ability and returns a true/false boolean if it exists or not. function temHabilidade(skills) { // código aqui } var…
-
4
votes2
answers686
viewsHow to join two object arrays by different keys?
I have two object arrays: let mergedScreensAllCompanies = [ { id: 1, description: Cadastro de usuários, }, { id: 2, description: Cadastro de filiais, } ] let userScreens = [ { id: 1, user_id: 1,…
-
4
votes1
answer90
viewsHow can I filter two values in my object array?
Hello! I’m having trouble understanding how I can filter the answer I get from my database, its logic is like this: I receive an array of objects from which it has the values of use, useridRequerent…
-
4
votes1
answer207
viewsHow to render the same component several times in React?
I’m trying to make a list with a component being repeated certain times. To be clear, I have a ScrollView and its own component PutANumber. I need the ScrollView has a predefined amount of…
-
4
votes1
answer60
viewsHow do I keep an original copy when using Sort in Javascript arrays?
I need to sort an array, but I can’t miss the original sequence. To do this, I created a new variable and assigned the value to it, making a copy of the original. However, when using the method…
-
4
votes3
answers109
viewsHow to compare arrays ignoring the order of the elements in Jest?
In a situation where I have two arrays, it is possible to use the expect of Jest for a comparison where I hope arrays are equal, regardless of the order of the elements? I searched, but found no…
-
3
votes2
answers531
viewsManipulating Array in PHP
I’m creating a PHP that creates Graphics using Google Charts, but I can’t supply the function with all the data in the array. When I print the function, instead of printing all the states of the…
-
3
votes2
answers3052
viewsHow to work with Postgresql array data types using Hibernate
How to perform object recovery and saving using type columns array using the Hibernate? In my case I want to save String. How I define in model the object? I found it on the net some examples but…
-
3
votes1
answer1217
viewsTransfer keys and values from a JSON to PHP variables
How to transfer data from a JSON:…
-
3
votes1
answer1535
viewsLocate the next "less than" value in an array
I have the following array and need to locate the next smallest value that defined in $valor: $seq = array(500, 490, 430, 370, 350, 240, 100, 90); $n_seq = count($seq); $valor = 400; // ASSUME…
-
3
votes1
answer2570
viewsWork with Struct and print problem, change Struct and delete Struct
I have a work at the college to do that consists of creating a structure of "Library Register"(cataloging code, name of the work, name of the author, publisher, donated works of each area, number of…
-
3
votes1
answer155
viewsCheck if a value corresponds to a value in an array
How to check if a given value corresponds to another present in an array? Ex: array1 ={nome = "Fulano", idade = 15} print(array1[idade].nome)
-
3
votes2
answers276
viewsResize into dynamic pointer turns dimension into garbage
I was responding to an implementation problem of Std::stack. It was easy, but I couldn’t use my first idea: Std::vector (replaced dynamic pointers forever). My code is: template <class T>…
-
3
votes1
answer1354
views