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
-
2
votes1
answer408
viewsHow to concatenate one vector into the other elegantly in ADVPL?
I have two number vectors, aBuffer and aCandidato. Depending on a condition (external to the vector), I need aBuffer receive the content of aCandidato to work on it afterwards. aBuffer will be used…
-
2
votes1
answer86
viewsRead matrix elements and print them
I created an algorithm that would receive a single variable with 9 different records that would display these values typed in matrix form (table). But when displaying the result, it is only…
-
2
votes3
answers345
viewsAn array index error
I’m trying to make an algorithm for Selection Sort, just to train algorithms even, in my view my logic is right about ordering, but it is returning me an error that I do not understand. Code: import…
-
2
votes1
answer123
viewsHow to compare responses and templates where each is a PHP string
I have 2 PHP strings that are the student’s responses and feedback. I need to compare them and show the result in a table: $respostas='1;A|2;B|3;C'; $gabaritos='1;A|2;B|3;D'; I need him to generate…
-
2
votes2
answers157
viewsSort an array of strings with dates
I have the following array: let datas = ["nov/2018", "set/2018", "jan/2019", "dez/2018", "out/2018"] when executed datas.sort() it orders by alphabetical order, however, I must order first by year…
-
2
votes2
answers79
viewsArray php not displaying key with same value
I have an array of hours(s) and an array of Schedule(s). When a customer makes an appointment, this time goes to the agenda array. 2 Customers scored the 08hrs, 3 clients the 09hrs ... same as this…
-
2
votes2
answers558
viewsCheck values within a JSON
In Javascript I’m getting a JSON like this: function checaEad(){ var urlEad = 'http://urljason.json'; $.getJSON(urlEad, function(data) { console.log(data); }); } He returns it to me:…
-
2
votes3
answers362
viewsHow to insert a new key associated with a new value at the end of a PHP Multidimensional Array
I have a multidimensional array with the following structure below: Array ( [0] => Array ( [id] => 1877 [type_id] => 4 [service_id] => 1100 ) [1] => Array ( [id] => 2299 [type_id]…
-
2
votes1
answer197
viewsHow to separate sequence of numbers in an array
For example, the user places in a textarea "1234 5678 1011 1213" I made a system that puts point and comma in each space, now I need to know how to store a digit sequence in an array, so I can make…
-
2
votes1
answer464
viewsI need help showing all the items in an array with Javascript
I am using AXIOS to access the API and can return only the first result. I copied only one part of the code below, but everything works perfectly when I enter the index [0].…
-
2
votes2
answers107
viewsVue.js: how to relate values in an array of strings?
I have the following problem, I have an array of strings that assembles a list: ex: op: ['100', '101', '102', '103', '104', '200', '201', '202', '300', '301', '303', '500'] From that list, I create…
-
2
votes3
answers110
viewsTake an object from within an array and send it to another array?
I need to take an object from within an array and send that same object to another array. See: todasAsCartas:[ { id: 1, valor: 2, naipe: 'Paus' }, { id: 2, valor: 2, naipe: 'Copas' }, { id: 3,…
-
2
votes0
answers281
viewsArray in the jokenpo
I’m making a game of jokenpo and it should have an option of how many players (multiplayer) will play, which can be, 3 humans and 2 computers, or more. But I can’t get him to receive this option…
-
2
votes1
answer260
viewsCall method with defined vector elements parameter
Good night! I have created a method that calculates the elements of a vector and makes the general mean, but I am not able to call it in the main method. PS: I am a beginner. Thanks for your help!…
-
2
votes1
answer299
viewsSave items from a Checklist form in the database - Laravel
I have a Checklist form that is generated dynamically. When saving the array persists in the error message: Array to string Conversion (SQL: update checklist_protocolo set projeto_id = 4, modelo_id…
-
2
votes2
answers147
viewsObject Array (not objects) in Java - How to use
Hello, I have the following task to do: I have three types of employees (Commissioned, Salaried and Hourly) and I have to add them to a list (ArrayList) to manage them. ArrayList<Commissioned>…
-
2
votes2
answers109
viewsC Programming - Two-Dimensional Matrices
**Matrix Print Error.Cannot generate matrix lines. Note, without using another library** #include <stdio.h> int main() { int nlinhas,mcolunas; int matriz[nlinhas][mcolunas]; int n,m;//n…
-
2
votes2
answers107
viewsUse "Array.prototype.filter" to list what you do and what is not part of the condition
Is there any way to make one filter in an array and retrieve what it does and what is not part of the condition? For example the following object: { "data": [ { "item": 1 }, { "item": 2 }, { "item":…
-
2
votes1
answer1915
viewsError: Collection modified; maybe enumeration operation is not executed
I have a problem using the foreach to traverse a array of strings. This component is a search button to select files, it selects and writes the address of the file into a array of strings, i created…
-
2
votes1
answer229
viewsPython Multidimensional Array Problem
Basically my algorithm imports all the photos I have inside a directory (dataset_train), saving these photos in vector X and the name of the folder where it was in vector Y. import os import cv2…
python array image-processing multidimensional-arrayasked 5 years, 5 months ago Felipe Ricardo dos Santos 46 -
2
votes1
answer53
viewsHow to restructure the index of an array - php
Good afternoon, everyone, I am in need of the help of vcs. Here’s the thing: I have an array that was created from a CSV file of client contacts. In this file what interests me most are the cell…
-
2
votes2
answers72
viewsMerge two arrays with whitespace
I have two arrays: const array1 = ['lorem','ipsum','teste','','hello','','vol'] const array2 = ['lorem','ipsum','teste','array2Tes','','world','vol'] How do I merge the empty parts of the first…
-
2
votes1
answer339
viewsPermutation between arrays in Java
I am trying to create a code that generates a data matrix. This matrix consists of all possibilities between certain arrays. My arrays are: [Corretor, Clientes] [Para Voce, Para sua Familia, Para…
-
2
votes1
answer210
viewsTake the last value of an Array inside a Foreach
I’m making a foreach which brings the following database: $notificacoes = Notificacoes::where('user_id', $id) ->where('lido', false) ->orderBy('created_at', 'desc') ->get();…
-
2
votes1
answer187
viewsHow to print vector formatted in Shell?
I’m trying to get a string and change only one of its values, and that’s easy using vectors. However, when printing the string, the vector leaves without formatting, I have tried to print it with…
-
2
votes2
answers328
viewsAssemble question and answer array
How do I mount this array, few times did foreach of unserialize, with that I’m having a hard time making this assembly. Model PHP <?php // $campoBD é a simulação do valor vindo do mysql pela…
-
2
votes1
answer50
viewsFind diff between different arrays
GOAL I have two arrays where it contains different formatted information, but the data is the same, for example on ARRAY1 the CLIENTE1-00 and the same as CLIENTE1 of ARRAY2, I just need to do a…
-
2
votes3
answers41
viewsAssign new items in an array without rewriting the whole code
Is there any way to add new items without rewriting the code ? See: If there are cookies then I use CURLOPT_COOKIE If not, I don’t use: if ($cookies) { $options = [ CURLOPT_URL => $url,…
-
2
votes1
answer1334
viewsFilter an object array within another object array
I have an array like the one below and would like to filter it by the property that is inside an object inside an array that is inside another object. The idea would be to return all objects whose…
-
2
votes2
answers544
viewsHow to scan an array of objects and return their values in a string
I have this vector of objects here: var usuarios = [ { nome: "Diego", habilidades: ["Javascript", "ReactJS", "Redux"] }, { nome: "Gabriel", habilidades: ["VueJS", "Ruby on Rails", "Elixir"] } ]; and…
-
2
votes1
answer53
viewsCode ". exe" stopped working
When adding new emails appears the message: project-Email2.exe has stopped working int op = 0, quant = 1; string nomeEmail[quant][2]; while(op != 5){ cout << "Selecione a opção desejada\n[1] -…
-
2
votes1
answer356
viewsDynamic string allocation in an array
I have a problem to store a vector dynamically need to save 10 names but I’m not knowing how to access this data for later printing follows my attempt #include <stdio.h> #include…
-
2
votes1
answer284
viewsI try to run a python function and it returns me None
Sorry if my question seems silly I’m still novice but it’s the following, I created a python function that should return me a list with this character in "~". Here is the function: def…
-
2
votes1
answer140
viewsArray problem in C, where is the error?
I have the following problem to solve: I arrived at this solution: #include <stdio.h> int main() { double numeros[99]; double resultante[49]; int i, j; for (i = 0; i <= 99; i++) {…
-
2
votes1
answer88
viewsIncrease multidimensional array size at runtime
Problem: I maintain a 2D multidimensional array that has a dynamic size, is always growing, as I am not allowed to use vector I need to develop a strategy to increase the size of this array at…
-
2
votes2
answers138
viewsGet object inside an array that has the lowest value in a specific Javascript key
I got the following array object: const cores = [ { cor: 'amarelo', peso: 2 }, { cor: 'amarelo', peso: 3 }, { cor: 'verde', peso: 7 } ]; My goal is first to filter it to return only the objects with…
-
2
votes1
answer128
viewsMap method is undefined in React
I’m building an application in React and need to render a list of all users, called the API. Use the map to go through the users, but the browser returns the error: TypeError: Cannot read property…
-
2
votes2
answers71
viewsObject array gives error when I try to access an element of it
package br.com.cursoemvideo; public class Olho { private String cor; private boolean funciona; public String getCor() { return cor; } public void setCor(String cor) { this.cor = cor; } public…
-
2
votes2
answers89
viewsSearching for letters in an array created by random numbers
I created an array with random values between 65 and 90 and turned it into an array of letters. So far so good. How do I find in this list (if it exists because it was created randomly) where the…
-
2
votes1
answer69
viewsimage processing (KNN classifier) - python
When using Kneighborsclassifier, I am getting the following error: /Feature Extraction (Python)/KNNpy:58: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please…
-
2
votes1
answer26
viewsNavigating between the contents of an array
Studying about array I understood that array = document.querySelectorAll(".nomeClasse") returns an array that contains each element that uses this class. But it’s still unclear to me how you access…
-
2
votes1
answer29
viewsUndefined value in last iteration to traverse nested array
I made the following code with the intention of traversing the following array: [[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]] Everything is happening as I wanted, all…
-
2
votes1
answer112
viewsMounting ranking with sorting criteria with array
I need to sort this Array initially by points and if there is a tie, those indexes of the array that tied would be unpacked in the games, if it remained tied would jump to tiebreak and if it…
-
2
votes1
answer85
viewsDifference when using an object and an array being passed as this no apply using the Concat function
I am studying Javascript and came across this difference when using an object and an array being passed as the this in the apply using the function concat. In the first case I use the this as an…
-
2
votes2
answers165
viewsAnswer coming out only true for all elements, or false
I was solving a question where there are two functions. The first function is to know if the value is true or false with two parameters, if it is equal to or less than the second parameter will be…
-
2
votes1
answer1417
viewsHow to create an object array with React useState
I’m trying to do the following procedure at React Native, with the Expo: I have some data stored in Asyncstorage of the device. The code below returns me the following result: CODE…
-
2
votes2
answers170
viewsI want to generate 4 random values from an array. How can I do it?
I’m looking to generate 4 random values from an array. I’ve tried using Math.Random, but it’s in an infinite loop... import React, { useState, useEffect } from "react"; import api from…
-
2
votes2
answers290
viewsWhen printing an array elements are not shown
I am trying to solve a problem where I have to read the lines of a file . txt and separate the numbers of this line and save in a vector. public static void main(String[] args) throws IOException {…
-
2
votes1
answer64
viewsCalculate 2 different array element totals according to the value of another property
My goal is to separate the sum of only women’s wages into one filter + reduce and the sum of men’s wages in another using also filter + reduce. The console.log(salarioMulher) in the last row is…
-
2
votes2
answers188
viewsLocate the index of the highest and lowest value of an array
How do I locate the position of the largest and smallest element in a Javascript array? With the reduce I was able to locate the largest and smallest element, but I need to get the position (index)…