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
-
0
votes1
answer87
viewsJavascript array with JSON object
I have the following objects: var category = [ {"category" : "fruity"}, {"category" : "Cakes"} ] and var products = [ {"description" : "Apple", "price" : 12.99, "category" : "Fruity"},…
-
0
votes1
answer50
viewsArray and Glob Doubts
I’m wanting to pick up 2 foreach entries and file one based on another, for example. in one foreach I have the value "stackoverflow" and in the other I also have the same, and then one cancels the…
-
0
votes1
answer935
viewsHow to inform the largest consecutive sequence?
Guys I’m hooked on this algorithm where I create an integer vector with n positions and need to show the longest consecutive sequence. I will leave the statement to try to be more specific.…
-
0
votes1
answer46
viewsHow do I merge into two array, but toggle them. (python)
array0 = [1,2,3] array1 = ['a','b','c'] having the two arrays above, as return this value that is below? //[1,'a',2,'b',3,'c']
-
0
votes1
answer304
viewsHow to take a user’s ID in a Listview and use as a variable in another Activity?
I’m doing my TCC and I’m having trouble removing the ID of some user from Listview and using it in another Activity (The intention is that when the user holds the click on someone from the list, a…
-
0
votes1
answer578
viewsCompare two object arrays?
I need to compare 2 arrays in Javascript, one that returns from a Mongodb query and the other comes from the email provider. The two comparison criteria are the email ID and the box to which it…
-
0
votes3
answers848
viewsReturn divisible by number in an array
I need to traverse an array in Javascript where I should search among the numbers of array the first number divisible by the number that the user will inform and that is non-zero. I tried to create…
-
0
votes1
answer69
viewsHow to turn a random vector into an ordered vector without losing correlation in Matlab
Hello, I’m trying to run a power flow program (electrical engineering). The routine works perfectly if the bar number vector is of type: A=[1;2;3;4;5;6;7;8] The problem is that I come across vectors…
-
0
votes1
answer574
viewsput image in a PHP array
I have an event counter on my game site, where I wanted a git to appear before the event name. I need a hand where I would follow that order. Next: gif image. zombie: php layout. <div…
-
0
votes1
answer348
viewsC vector product with file input . dat
Be the code below, where the input vector.dat file, on each line, has 6 numbers where the first 3 are components of a vector "u" and the last 3 are components of a vector "v". The vector.dat output…
-
0
votes1
answer69
viewsLaravel Controller?
How I can style an object into one array in the controller Laravel? Mapper::marker($marker['lat'], $marker['lng'],['label'=> "<div>".$marker['label']."</div>"]); Controller public…
-
0
votes1
answer234
viewsString for an array within a loop - javascript/nodejs
i want to pass the strings of a txt file to an array and as soon as each line was passed to the array the program would run it normally, then he would repeat and pick up the second string of the txt…
-
0
votes1
answer35
viewsReturn all values of a given property in a Javascript object array
I have a certain array var people = [ { name: 'Leandro', age: 36 }, { name: 'Joaquim', age: 29 }, { name: 'Maria', age: 25 } ] If I want to return the name property at the first position I do the…
-
0
votes1
answer74
viewsSearch within two arrays
the case is the following. I have a script that I wanted to use and as in all questions "I suppose" I do not know how to do. The following I want to do an array data search with javascript "pq do…
-
0
votes2
answers65
viewsCheck if there is a specific value within a java bi-dimensional array
I need to check if there is a specific value in case the value 1 within a bi-dimensional array for the code return if a value is true or false. The code I used was the following : for (int i = 0; i…
-
0
votes3
answers125
viewsCheck whether an item exists within an array, using a variable
Let’s say I have this array: let checkOne = [ { "id": 273, "attributes": { "humidity": { "qty": 74.3223333333333, "unit": "percents" }, "protein": { "qty": 23.525, "unit": "g" }, "lipid": { "qty":…
-
0
votes1
answer213
viewsarray repeating results
I don’t understand why my array is repeating the results, my loop to go through it is like this: for ($i = 0; $i < count($estados); $i++) { foreach ($estados[$i] as $key => $valor) { echo…
-
0
votes1
answer65
viewsTake values from a vector and use in a function
I have a vector XC[i] where Gero with the code below: for(i = 0;i<N_Volumes;i++){ double XC[i]; XC[i] = (xC0+=delta_x)-1.0; printf ("XC[%d]= %f\n", i, XC[i])}; I want to take these values from…
-
0
votes4
answers123
viewsIs there a smaller way to resolve the question below? and know if it is correct
Create an algorithm that contains an integer vector. Then, your algorithm should generate two more vectors. The first vector must store the numbers of the initial vector in ascending order and the…
-
0
votes2
answers1613
viewsPlace two Arrays inside a foreach
Well, in case I have two arrays that are received from inputs, based on renting rooms from a hotel, in case each room needs to display number of adults and children, I got help from someone here in…
-
0
votes1
answer98
viewsStrange values when generating array in a dynamic object in PHP
Follow this example code: class Object{ private $keys = []; private $values = []; public function criarArray(){ $obj=get_object_vars($this); foreach($obj as $key => $value): $this->keys[] =…
-
0
votes2
answers46
viewsPrint a new vector by changing the order of the elements of the original vector
How do I change the order of the elements of a vector v1 printing a new vector v2 with these changes? You can write a function def? Example: v1 = [2,51,68,10] v2 = [10,2,51,68]…
-
0
votes1
answer70
viewsInvalid argument supplied for foreach() with correct supplications!
Guys I have the following resource in php: array(3) { ["name"]=> string(12) "module teste" ["status"]=> string(1) "1" ["banner_image"]=> array(1) { [1]=> array(1) { [0]=> array(7) {…
-
0
votes1
answer43
viewsSelect values from another table with more than one row in Websql
I’m using Ionic + Ordova + Websql. I have basically these tables, partners and partiesEnderecos. In the address table can contain more than one row for each partner. How do I return these values? I…
-
0
votes2
answers266
viewsProblem with reduce to calculate arithmetic mean of array
Doubt with the method reduce. I cannot perform the arithmetic average calculation, the result even worked once (4,375), however, the code only adds up after a first execution. I’ve checked the…
-
0
votes0
answers110
viewsHow to access the properties of an object within an array in Javascript
I’m a beginner in Js, studying arrays, I wondered how to access a specific information of an object inside an array For example if I wanted to access only the name Diego and his skills and give a…
-
0
votes1
answer210
viewsUse Searchview to search for a populated model class with firebase
Good night ! I am stuck in a problem, in this I have a list of items I receive from firebase, in this list I have visibly 3 attributes of the model class (idAtivity, title and time), thus, I would…
-
0
votes1
answer167
viewsHow to transform an array of arrays into a nested array in python
I’m looking to transfer an array of arrays in a nested numpy matrix, i.e.: array[array[1,2],array[1,2,3],array[8]] in array[ [1,2,nan], [1,2,2], [8,nan,nan] ]. That’s right when I convert to pandas…
-
0
votes1
answer30
viewsHow do I get this matrix to zero in front of the F’s?
I can’t leave the matrix zeroed in front of the F’s. it’s just behind.…
-
0
votes1
answer128
viewsHow to use v-for with components, using array?
I’m using the question below to better illustrate my question. Vue is not rendering table with v-for, how to solve? How do I do the same thing? Only by displaying a listing, using a component, but…
-
0
votes1
answer753
viewsGo through array and check if a field is empty (PHP)
In one of the files I have a dynamic table that receives data from BD, but with the possibility of inserting more rows in the table. Note that when inserting more rows the idFaturacao will be empty.…
-
0
votes1
answer33
viewsDoubt about sum of information
I’m doing some exercises on composite variables and I’ve reached an impasse in my code, which at first I can’t solve despite it seems to be something simple. At the time of the display of the…
-
0
votes2
answers1347
viewsInserting data using PHP array
I have a table and need to insert data from this table through an array. However gives this error: Notice: Array to string conversion in C:\xampp\htdocs\PhpProject1\salvar.php on line 17 My Index…
-
0
votes3
answers1242
viewsPHP-Loop repetition table using multidimensional array
Hello, I need to make a table like the one in the image but using this array: $teste = array(); $teste[0]['produtos']['nome'] = "Produto 1"; $teste[0]['produtos']['descricao'] = "Descrição do…
-
0
votes1
answer52
viewsIncrement an array with PHP foreach
I have a foreach that where I need to add the value of the variable to a array: foreach ($xml->NFe->infNFe->det as $itens){ $quantidade = round($itens->prod->qCom);…
-
0
votes1
answer52
viewsSubclass array of a superclass in Delphi XE7
I am trying to make an array of subclasses in this format: arrayReg : Array[0..1] of TRegDom = (TRegDom0000); Tregdom0000 being a subclass of Tregdom (Tregdom0000(Tregdom)) and gives an error of…
-
0
votes1
answer95
viewsDifficulties picking up values within an array
I’m making a code where I select database information and feed an array, then I’m trying to use the contents of that array to compare with other information and process the rest of the code. But I’m…
-
0
votes2
answers153
viewsError while displaying array in PHP
I have this array in PHP and I must display the users name and email field. But php display an error message: array(4) { [0]=> object(stdClass)#25 (5) { ["idusuario"]=> string(1) "2"…
-
0
votes1
answer171
viewsHow to put class information in an array?
To save lines of code, I do the following: PictureBox[] pic = { pictureBox1, pictureBox2, pictureBox3, pictureBox4, pictureBox5, pictureBox6, pictureBox7, pictureBox8 }; And I have a class called…
-
0
votes0
answers32
viewsHow can I shuffle a vector with structures? C
I need to shuffle domino pieces on a function, and I’m having trouble. void baralhar(int domino[]) { srand(time(NULL)); for (int i=1;i<=29;i++) { int r = rand() % 28; int aux = domino[i];…
-
0
votes0
answers25
viewsmatrices without size in C
I have a doubt that came to me while learning about matrices of a dimension (no size). Follow an example: #include <stdio.h> int main(){ int matriz[] = {1,2,3}; } My question is: and if I then…
-
0
votes1
answer117
viewsArray saving data in the database with a field written array
I have two fields saved in the database (in this case it would be as a comment on the request in the Brazilian language, but that doesn’t matter much). These fields are being saved correctly, but…
-
0
votes0
answers35
viewsArrays error - how to store a div element
The goal is to exchange the letter r for and to form the pre HTML element. I’ve had experiments with my code where I have an array of Divs where each div stores a letter. To swap the elements just…
-
0
votes1
answer49
viewsData from an Array (Angular)
I’m trying to use data from an Array to place on an object.. for example: lembreteSistemaList = LembreteSistema [] = []; lembreteSistema = LembreteSistema = new LembreteSistema(); recuperarLembrete…
-
0
votes1
answer41
viewsI need to change the output of a variable in Python
My variable a, imported from a file .mat, has as output: array([[0],[1],[2],[3],[4],[5]]). I need the output of the variable a be it: array([0, 1, 2, 3, 4, 5]) How do I make this correction/change…
-
0
votes1
answer65
viewsHow I remove the String from inside a Sequelize return
I made a select by Sequelize and it brings me this: [ TextRow { permission: 'group.default' }, TextRow { permission: 'group.fundador' } ] But how do I get only the 'group.#' of that array? I want…
-
0
votes0
answers13
viewsHow to check if an array has values from another array?
Well, the problem is this, I have a function in which it requires a property permissions array type, inside the function, is a const perms = ['perm_1', 'perm_2', 'perm_3']. Let’s say the user has…
-
0
votes0
answers57
views(PHP/Laravel) Error adding a second item to the array does not increase the amount of the second item
My Controller public function Adicionar(Request $request) { $id_produto = $request->get('botao'); $itens = $this->carrinho->getItens(); //dd($itens); try{ foreach($itens as $item){ $est =…
-
0
votes1
answer77
viewsFilling table
I have a function, but I do not know how to make it recognize data with more than one registration linked to a code, for example I have this product code ABITAand it has 5 types and descriptions…
-
0
votes1
answer965
viewsArray in Ionic of json file
I have the following JSON document "descritores": [{ "descritor": "texto..", "resultado": [{ "MediaTotal": "81,16" }, { "MediaTotal": "81,16" } ] }, { "descritor": "Texto 2..", "resultado": [{…