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
-
1
votes1
answer56
viewsPassing by reference, and saving data from a file in a vector
I’m having trouble saving the read data from a text file and a vector from a structure I created. My goal is to open a text file, take the data that is saved in it, and save in an array of type…
-
1
votes1
answer1800
viewsConvert a JSON String to a JAVA Object Array
Hello, I’m not getting the conversion, my string is coming like this. { "empresa1": { "category_id" : "Item 1", "id" : 1, "imagePath" : "imagem", "name" : "empresa 1", "short_desc" : "desc da…
-
1
votes2
answers383
viewsArray within PHP Array
I’m creating a system where you can add drugs by protocols. Ex: PROTOCOL NAME [ARRAY] NOME DO REMÉDIO [ARRAY 2] NOME DO ITEM QUANTIDADE TEMPO DE INFUSÃO [ARRAY] NOME DO ITEM 2 QUANTIDADE 2 TEMPO DE…
-
1
votes1
answer64
viewsVariable that has a variable in its name
In an exercise: A company wants to know in how many months there was profit, that is, the balance greater than zero. The code for resolution was this: function quantidadeDeMesesComLucro(umPeriodo){…
-
1
votes1
answer75
viewsGroup and add arrays with equal properties
x [{produtoId: 5, quantidade: 10}, {produtoId: 6, quantidade: 20}, {produtoId: 5, quantidade: 7}] y[{produtoId: 5, quantidade: 17}, {produtoId: 6, quantidade: 20}] I need to transform the X array…
-
1
votes1
answer420
viewsCan you tell the size of an array in Visualg?
para i de 1 ate array.length faca escreval("Falta ", i, "?") leia(falta[i]) i <- (i + 1) fimpara For example, in Java it is array.length.…
-
1
votes2
answers256
viewsAdding a value to an object array with reduce
I have an array of objects that follow this format: [ { name: 'Batata', points: 23, }, { name: 'Pizza', points: 50, }, { name: 'Tacos', points: 60, }, ]; I want to go through this array and get the…
-
1
votes3
answers554
viewsExtract Array Data in Javascript
I own a array with the working groups that the session user belongs to, for example if I write like this: return $data.teste02[0].group_id.name It returns me the first group that this user belongs…
-
1
votes2
answers78
viewsUnderstanding the content of array elements
const funcs = []; for (let i = 0; i < 10; i++){ funcs.push(function(){ console.log(i); }); } funcs[2](); funcs[8](); I would like to understand why the result, funcs[2]() and funcs[8](), were 2…
-
1
votes1
answer880
viewsHow to filter values by keyword in the array?
The codes below are not working very well the way I want: $array = array('January', 'February', 'March', 'April', 'May', 'June'); function filterDataByValue(array $array, $value) { $filtered =…
-
1
votes3
answers866
viewsprint value of a given array with PHP
I have this array Array ( [0] => stdClass Object ( [product_image] => http://placehold.it/250x150/2aabd2/ffffff?text=Product+2 [product_name] => Product 2 [product_desc] => Product…
-
1
votes2
answers76
viewsError while creating string array
I’m having trouble trying to initialize a vector of strings my code is like this: #include <stdio.h> #include <stdlib.h> #include <string.h> int main(){ char *str[3];…
-
1
votes2
answers177
viewsPrinting of Matrices in Python
I’m starting in python and I need to solve several Python matrix exercises, but I can’t make the right impression. Understanding the Logica of this exercise I can solve the other quiet. Could…
-
1
votes2
answers126
viewsTake over positions of an array after comparison with another array?
I have a function (in Javascript) that compares 2 arrays: let diferencas = []; let numD = 0; for (let a = 0; a < dados.length; a++) { if (dados[a].idEmail === results[a].idEmail) {…
-
1
votes2
answers91
viewsIs it possible to assign the first column of a row of a/a vector/matrix?
taking as an example a two-dimensional vector of the type char 2x2: char vet[2][2]; Is it possible to assign to the first line indices of this vector? or they work like a pointer to the other rows…
-
1
votes1
answer599
viewsHow to recover PHP array for javascript comparison?
I have a code in javascript that sends some elements of the page to another in PHP via ajax and there are made some comparisons. Then it returns me this array with the function print_r() : However,…
-
1
votes2
answers1120
viewsHow to read Json with Android
I wonder how I read json in two different ways. 1 - I have a Json {"nome": "JOA", "cpf": 7.4417, "idade": "15"},{"nome": "PAT", "cpf": 8.5528, "idade": "20"}"}; This one I can read and play in…
-
1
votes1
answer95
viewsError in Python2
I’m practicing using Python 2, but I don’t know the reason for this error. Follow below my code with the error. And numpy and scipy are installed, because when I give the import no more error…
-
1
votes1
answer65
viewsRemove subArray from a Main Array
I have two main Arrays (listaInformacoesNota,listaInformacoesPedidosPostgreSQL) with N subArrays each, these subArrays have items in common and a different item only, I did the following to compare…
-
1
votes0
answers56
viewsSet method does not work for filling object array
I created a class Funcionário, and in class Main create an array of objects of this type. I am now trying to set the attribute "position" of employees in a loop, but gives NullPointerException...…
-
1
votes1
answer507
viewsCount arrays within PHP array
Good folks, I have the following array…
-
1
votes1
answer40
viewsprint array in the amount of values of another array
I’m new to php and have the following problem, I wanted to print an array with string values in the amount of values of another array with integer values. That must be it. $string =…
-
1
votes2
answers83
viewsFirst item returns Undefined
I’m trying to print on inner one split, however, after passing through the for, the first value returns as undefined, could tell me what it might be? function parteTexto() { var teste; var texto =…
-
1
votes1
answer121
viewsCode matching verification on a vector within a C struct
next, I created a struct struct eventos { int codigo; char data[11]; char atracao[50]; int ingresso; float valoring; }; And then I created a vector that way struct eventos ficha[5]; My goal is to…
-
1
votes1
answer112
viewsPassing array list by parameter
I have the following problem: I need to pass some files (xmls and pdf) from my winforms application to a webservice. The problem is that it is not possible to pass via parameters to a WS data type…
-
1
votes1
answer2656
viewsVector Union in C
good evening. I am with an evaluative activity of the college to be delivered but I can not think of logic and solve the first activity. Can someone explain to me where is my mistake and a piece of…
-
1
votes1
answer63
viewsReturn only an attribute of an object?
I would like to know how to get only one object attribute ... const person = [ { name: 'Jane', age: 55 }, { name: 'Rafael', age: 23 }, { name: 'Carolina', age: 19 }, { name: 'Bob', age: 47 }, {…
-
1
votes1
answer197
viewsArray has values, but its length is zero
I need to iterate on this array, however, although it is not empty the length of it returns 0 as you can see, someone knows the reason? The scenario is as follows: I am receiving JSON data from an…
-
1
votes2
answers979
viewsHow to replace string values from all array values?
Good afternoon guys, well the problem is this.. I have a string with name x, and I have two arrays, name and value. in for perco both arrays where I identify if in string X has any field equal to…
-
1
votes0
answers36
viewsSearch for matrix inside another matrix in Js
I wonder if it is possible to identify if a matrix is inside another javascript matrix. For example, if the matrix A is inside B or C inside A. I’m trying to apply the following code: a =…
-
1
votes0
answers36
viewsArray of pointers that point Functions
Good afternoon. I wonder if the code below is correct. I have a little bit of pointer difficulty and I entered this area of pointers to functions and I would like to understand more about this…
-
1
votes1
answer66
viewsNota1 and nota2 show errors and do not view storage in the array. Can anyone help? Thank you very much
namespace mediaDe5Alunos { class Program /*faça um programa para cálcular a média de duas notas de 5 alunos, mostrar a média da sala e de cada aluno e um relatório dos alunos*/ …
-
1
votes2
answers131
viewsInserting objects into an array through a loop
I am with a problem that I am not able to solve at the moment. I am trying and I cannot reach a solution. Basically I want to insert several objects into an array. What I’m doing is, I guess what…
-
1
votes1
answer43
viewsAsk the user which element he wants to remove from the Javascript Array
I am trying to create a program in which an element can be added or removed from the Array, according to what the user puts in the command prompt. I’m having trouble removing elements from the…
-
1
votes1
answer137
viewsSet associative array key
Consider this array: protected $filter = [ 'preco' => 'required;double(1,4)', 'email' => 'required;email' ]; Step by the foreach: protected function bootFilterPost() { foreach…
-
1
votes2
answers280
viewsProblem with pointer and array
I wanted to print the corresponding locations and values of a array using a pointer but when I ask the pointer to add the vector location to 8 (which corresponds to the 8 bits of an integer) the…
-
1
votes0
answers69
viewsHow to make an infowindow with different content for each marker in a loop
I’m trying to make each marker in this loop have an infowindow with different content, the arrays are the same size and are being taken from the database, the problem is that by creating new…
-
1
votes1
answer30
viewsProblems with C/C++ Struct Array
I’m trying to make a program that reads a string and int and stores its values in one struct and then print it on the screen, I’m still learning, forgive me if it’s a very obvious mistake. Code:…
-
1
votes1
answer510
viewsHow to turn pointer into matrix
I’m doing a program that transforms a matrix into a transposed matrix. I am using 3 functions because I want to learn how to pass parameters of arrays. The function main() calls the function…
-
1
votes0
answers120
viewsAngularjs - Json in Localstorage does not update Array
I have a form in a View that should update the "color" property of an Array. This Array colors has 5 objects, each serving to set the color of an element of another View (so the option to use…
-
1
votes1
answer159
viewsSort by id in Angularjs (Javascript)
I have an Angularjs object: $scope.listaDoCarrinho = [0: { id: "55", setor: "alimento", foto: "Produtos/Produto (55).jpg", descr: "Espaguete Renata", de: 15, … } 1: { id: "1000", setor: "biscoitos",…
-
1
votes1
answer67
viewsDoubt about the reduce method in Javascript
I took this small code from a material from the internet to print how many times a number repeats in the array, but I could not understand what was done, especially with this if and with the…
-
1
votes1
answer66
viewsWhen you click, I want to define the phrase through the indexes
As you can see in the code, when I click I’m randomly defining the phrase, but when I click, I want the phrase that I myself define through the indexes, how do I do this? Public class MainActivity…
-
1
votes1
answer396
viewsHow to organize an array by size automatically?
I was looking to create a ranking system. For this I thought to put all the values within one Array and then through a function arrange it from the largest to the smallest. However, each time I make…
-
1
votes2
answers841
viewsProblem with recursiveness and pointers
I am struggling to resolve the following issue: Make a recursive function that allows you to sum the even elements of an integer vector, you must use pointers to traverse the vector My code is not…
-
1
votes1
answer286
viewsconditional search in PHP using codeigniter
I have this table in my database I need to select all products belonging to a brand, but if the product code is the same you should not repeat the product, you should use the same product. Example,…
-
1
votes1
answer66
viewsHow do I check if a value already exists in my array?
My array has the structure below, before adding a new position, I would like to check if there is already "id_product" and if "Qtd" is still the same, I tried with the community answers but was not…
-
1
votes4
answers97
viewsFind a ( string ) value in a PHP array
I’m having trouble finding a variable value inside an array Example: I have the information below in some array. $dadosCli1 = array("cep:'000000'", "cidade: 'sao paulo'", "rg: '00.000.000.-00'",…
-
1
votes3
answers203
viewsCombine arrays
Well, I’ll try to explain a little better as you requested. I own 3 arrays simple, I’m using an example with 3 arrays, but actually the number of arrays is not defined as they are mounted from…
-
1
votes1
answer45
viewsObject Keys of a JSON is saving the last value
People when I run Object Keys it captures the entire Object Array and updates the data of the component only not all and the output only comes the last Array value: var obj = { index: { path: "/",…