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
-
3
votes2
answers221
viewsCreate a vector with the Levels of a factor in r
I have a column in my data matrix as follows: > as.factor(matriz$especime) [1] 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 [29] 3 3 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7…
-
3
votes3
answers130
viewsStore PHP array value and quantity
I need to sweep the first array and store the value and quantity of that value in another array. I’m not succeeding because I’m having trouble storing the values in another array. Array: array(5) {…
-
3
votes1
answer601
viewsReturn local function variables
I have two methods: // Apenas define um vetor de 4 posições e retorna ele int *verticesFromFace(int v1, int v2, int v3, int v4) { int vertices[4] = {v1, v2, v3, v4}; return &(vertices); } //…
-
3
votes3
answers1433
viewsHow to create list in Haskell
How do I create a function that takes a list (can be dynamic or static) and returns the n-issimo element of that list? I use the Haskell language.
-
3
votes2
answers6203
viewsUse array_search in a php multidimensional array
In a list of books within a array multidimensional, each sub_array has a column category different, I would like to search in this array by a category for example: Array "livros" ( [Livro 1] =>…
-
3
votes2
answers319
viewsForeach with PHP Stdclass
My page shows posts that have been registered in the database. Some posts have files that have been uploaded. These files are saved in server folders and the database has the table "Archive" with…
-
3
votes1
answer1364
viewsHow to check if two vectors have equal values quickly
The element number reaches 100000 and I have to compare with another vector of 100000, as I can do it with a very high unemployment gain How I’m comparing the vectors for(i = 0; i < teste; i++) {…
-
3
votes1
answer61
viewsDifferent ways to create an iterator for values
Is there any difference between creating a iterator for the values of an array using these two forms? let myIterator = arr[Symbol.iterator]() let myIterator2 = arr.values() I’ve run some tests, and…
-
3
votes1
answer82
viewsHow to insert a variable into an array?
I want to enter data in my database I’m using mysqli, I need to know how to indicate inside an array a variable, here and my code I want to know if this is the correct way to do it require…
-
3
votes3
answers962
viewsPrinting a character in place of a number
#include<stdio.h> #include<string.h> int main() { char str[50]; int i, l = 0; printf(" We will count the number of letters\n"); printf("-------------------------------------\n");…
-
3
votes1
answer64
viewsPass an array of a form to PHP via AJAX
I have this form: jQuery (function($) { AddTableRow = function() { var newRow = $("<tr>"); var cols = ""; cols += '<td><input type="text" name="dados[][nome]" id="dados[][nome]"…
-
3
votes1
answer106
viewsPHP Array for JS Array
I have the following array in PHP Array ( [0] => Array ( [Funcionarios] => Array ( [id] => 3 [nome] => Funcionario Teste [assistmed] => 10 [assistodont] => 1 ) ) [1] => Array (…
-
3
votes2
answers162
viewsHow to make an object in Listview have an absolute position?
I have a listview with several items, I also have right up a searchView to perform a filter on these items, being they "clickable", starting another Activity. The problem is that the numbering of…
-
3
votes1
answer261
viewsCount vector elements and place links on the page
I want to make a script which counts how many vector tiles I have inside new Array. Example var array = new Array('001.html', '002.html', '003.html', '004.html', '005.html') .. and add them in the…
-
3
votes2
answers276
viewsHelp with Java Exercise
I’m having a little problem in a JAVA exercise, I can’t fix it, although I’m pretty sure it’s pretty simple. It’s a simple crud: Below is the main code import java.util.Scanner; public class Crud{…
-
3
votes4
answers717
viewsIn a sentence, how to know which word has the least characters?
In a sentence, how to know which word has the least characters? What I did was turn the string into an array, but I could only return the smallest when it comes to an array of numbers, using…
-
3
votes1
answer3361
viewsLoop for inside loop for
for(pass = 0; pass < size - 1; pass++){ for(j = 0; j < size - 1; j++){ if(array[j] > array[j + 1]){ swap( &array[j], &array[j + 1]); } } } I put only a piece of code where I have…
-
3
votes1
answer169
viewsI want to count and quantify the Array index on onclick control
I want to create a simple element-based pagination within an array. When arriving at the first and/or last element of the array, I would like to disable the respective navigation button (e.g., by…
-
3
votes2
answers1096
viewsHow to set custom name in Javascript array index?
In PHP we can use: $validation = [ 200 => ['icon-check', 'The key match with the message!'], 400 => ['icon-close', 'The key doesn\'t match with the message!'], 403 => ['icon-close',…
-
3
votes2
answers354
viewsHow to generate an array of years dynamically containing the index as the year and the value as the year itself?
I have a routine that generates a list of years dynamically from an initial year defined in the array which in this case is the year 2015 to the current year. See the array structure: $rray = array(…
-
3
votes3
answers4175
viewsHow to change a PHP array’s key
I need to change the key of an array $task=array('Title' => 'Test', 'Description' => 'Description test') I need to change the key name Description Is there any way? I’m working with the…
-
3
votes3
answers953
viewsSelect higher PHP value
I got the following: $gols = array("Kraken"=>"25", "Cleiton.Xavier"=>"10", "Buffon"=>"0", I wanted to find the greatest value of $gols and the name of the player also as I do?…
-
3
votes4
answers806
viewsOrganizing positions of a vector
I need to create two vectors, with 3 elements each and real numbers Then copy these values to a new vector with 6 elements The first 3 values must be of the vector with the highest summation value…
-
3
votes1
answer168
viewsHow to organize an array of a list
An array that looks like this: Array ( [nome_e_sobrenome] => Array ( [0] => Luiz Felipe Machado [1] => Maria Rita de Cássia ) [usuario] => Array ( [0] => luizf [1] => mariar )…
-
3
votes3
answers490
viewsHow to use foreach in Javascript associative array
I am seeing here that the length of an associative array in JS is reset.. As I access these values then? Example: let myArray = []; myArray['zero'] = 0; myArray['um'] = 1; myArray['dois'] = 2;…
-
3
votes1
answer121
viewsIterate an array (vector) via Ienumerator? For what reason?
In which case it would make sense for me to give up iterating a array using loops "normal" (for/foreach/while) via index to use the IEnumerator as shown in Example 3? Example1 //Usando for int[]…
-
3
votes2
answers63
viewsRandom numbers appear later in sorting algorithm
At the end of my program the result is giving random numbers, which occurs? main(){ int i; int a[10]; int x; int aux; for (i=0; i<10; i++){ printf ("Entre com os numeros %i: ", i); scanf ("%i",…
-
3
votes1
answer54
viewsDoubts about how to rederizate ordered and organized array in v-for
I own a array from that JSON: [{ "cod_recurso": 36, "ativo": 1, "nome": "Aceita Animais de Pequeno Porte", "icone": null, "ref_cod_categoria": 4, "data_cadastro": "2018-11-19 10:44:19.24543",…
-
3
votes2
answers944
viewsHow to insert an item into a particular php array position?
I have the following array, $status = array(); $status["Visualizar"] = "Visualizar"; $status["Editar"] = "Editar"; $status["Status"] = "Alterar Status"; $status["Boleto"] = "Gerar Boleto"; It turns…
-
3
votes1
answer184
viewsWhat is the difference between arrays vs. Collections in C#?
Concerning arrays and Collections in C#, vary from application to application or there is unanimity between them?
-
3
votes1
answer32
views'Search in All' using Linqjs
I’m using the linqJs When I try to get the id 5512 he returns null, but when I catch the 124, works. $.Enumerable.From(structure).Where("$.id==5512").ToArray(); Object structure: [{ "id": 124,…
-
3
votes1
answer203
viewsReturn Array inside the other
I have the following array Array ( [0] => Array ( [id] => 232 [menu] => Energia [logo] => fa-bolt [url] => # [submenu] => Array ( [0] => Array ( [id] => 209 [menu] =>…
-
3
votes1
answer607
viewsHow many elements does an array have?
I have a array of 10 positions which is filled through a function, ARMultiEachMarkerInfoT marcadoresVisiveis[10]; always before adding elements to the array, the function clears all elements and…
-
3
votes2
answers205
viewsWhy do some functions that work with C strings start with *?
In one of our classes we were taught that when a function receives as a parameter an array it is actually receiving the memory position in which it is allocated so it is not necessary to return any…
-
3
votes3
answers75
viewsDefinition of "arrows" in PHP
I don’t know if I got it very well in the official php documentation (https://www.php.net/manual/en/language.types.array.php), so I came here to ask a question. I’m giving a general review, finally…
-
3
votes1
answer90
viewsMoving piece, adds new game board
Good morning, I’m having a little problem drafting a board game. When I try to move a tile by returning a new frame(array of arrays), it is added to the page instead of replacing itself. I get two…
-
3
votes2
answers91
viewsForeach preg_match_all
I need to mount an array with all the data coming from another array using preg_match_all,I’m using the following code. $results = array(…
-
3
votes1
answer10220
viewsGenerate random numbers in C?
I need to generate 5 random numbers in a range between -10 and +10. How could I do this ? I’ve seen that one can use shuffle, malloc or even realloc, but being new in C, I don’t quite understand how…
-
3
votes1
answer129
viewscalculate percentage of iterated items in a loop
How to get the percentage of total items in an array that have been processed in a loop? Example: // array fictício (238 itens) var arr =…
-
3
votes1
answer365
viewsHow to store vector values?
I’m a beginner in C and I’m 2 days into this exercise, I was able to do it so that if you increase the vector with the function realloc, it will increase everything right, but I need him to keep the…
-
3
votes1
answer1083
viewsLimit contents of an Array
How can I limit the number of values/indices of a array? For example: let arr = [1, 2, 3, 4]; console.log(arr) // Exibirá: [1, 2, 3, 4] Goal: //Reduzindo o limite de índices do array para 2:…
-
3
votes0
answers113
viewsReturn repeated elements within an array
How to pick up only the repeated elements within an array? I have for example: let array = [1, 2, 2, 2, 3, 3, 4, 4, 5, 6, 8, 8, 9, 9]; And I want to return all duplicates to get: [2, 3, 4, 8, 9 ] If…
-
3
votes2
answers545
viewsCheck string is contained in PHP Array
I have a function in Curl, its return is an indefinite amount of data, but, its format is standard. Return: array(86) { [0]=> array(2) { ["value"]=> int(1) ["data"]=> string(27) "retorno 1"…
-
3
votes1
answer63
viewsWhat is the parameter passed in Sort()
Doing an exercises I came across the following parameter passage in sort(): let notas = [7,6,10] notas.sort((a,b) => a < b ? 1 : -1) console.log(notas) I could not understand, since I have…
-
3
votes4
answers876
viewsHow to capitalize all words in an array using toUpper?
The function needs to return all words of the array in uppercase. function transformaParaMaiusculo(palavras){ for (let i=0; i<palavras.lengh; i++){ palavras.push(palavras[i].toUpperCase()) }…
-
3
votes2
answers466
viewsHow to merge two multidimencional arrays, disregarding repeated values?
I have two arrays multidimensional. An array I’m bringing from a file . json, the other is coming from one POST via Ajax. My idea is to generate a new array with the merger of these other two arrays…
-
3
votes2
answers275
viewsHow to write a program that fills a 10-position vector with random integers between 0 and 20?
How do I create a vector v of 10 random elements in which each element is one whole between 0 and 20? I tried to use the function np.random.random((1,10)), but the output was a vector of decimal…
-
3
votes4
answers2518
viewsHow to count occurrences of a value within an array?
How to take the amount of times a string repeats within an array? Ex: var teste = ["oi", "tudo", "bem", "oi"];
-
3
votes2
answers131
viewsBreak string into array limiting the amount of times the break is made
I know we have the split to break the string in array, but if I want to split only the first time you find a certain feature? Example: const vogais = "a-e-i-o-u" const arrayVogal = vogais.split('-')…
-
3
votes1
answer372
viewsDelete equal values within a dynamic array
I have an array with several dynamic names that can change each time, what is the most correct way to go through this array and create a condition to delete them iguail? (in the case of two items…