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
answers403
viewsPass list of objects between files
How to pass a list of objects through two Javascript files? I have a list: var elementsList = []; And this list is populated with N objects: var oElement = { elem: "", emin: 0.0000, emax: 0.0000 } I…
-
3
votes2
answers836
viewscheck whether GET exists or not
I created an array by calling names, within this array I have 3 names $nomes = array ('carlos', 'maria', 'jose') Later on in the code I’m trying to create an if where I check if the GET value exists…
-
3
votes1
answer1514
viewserror in getting values from stdClass php array
When I use echo var_dump($location); I get this: object(stdClass)#1226 (2) { ["type"]=> string(5) "Point" ["coordinates"]=> array(2) { [0]=> float(44.0928438) [1]=> float(-70.20876942) }…
-
3
votes1
answer3650
viewsSort object array
I have as a result of a query to the database the following data: Array ( [0] => stdClass Object ( [id] => 1 [nome] => Pizzaria 1 [latitude] => -8.12044775643893 [longitude] =>…
-
3
votes0
answers150
viewsIs it possible to capture an item from a json array to change an attribute from a rect in raphaels.js?
I would like to make an array that can serve as a database for my map represented by these 3 rectangles. The array will contain numbers that will serve as indicators for rectangle colors, If item 1…
-
3
votes1
answer128
viewsTake array name within array
Well, what I want is the following: take the name of an array within another array, just the name. EX: local a = { ["oi"] = {sim=1, nao=2}, ["tchau"] = {sim=2, nao=1} } local falas = {}…
-
3
votes1
answer107
viewsPrint does not return table values
pokecatches = { ["Bulbasaur"] = {chance = 150, corpse = 5969}, ["Ivysaur"] = {chance = 275, corpse = 5982}, ["Venusaur"] = {chance = 400, corpse = 5962}, } print(table.maxn(pokecatches)) corpses =…
-
3
votes2
answers873
viewsDifference between two Multidimensional Arrays with PHP
I have these two multidimensional arrays and would like the difference between them, similar to what the function array_diff does, but with multidimensional arrays: $array_1: Array ( [0] => Array…
-
3
votes4
answers3610
viewsReceive an array in the controller from javascript
I am creating an array with a javascript data list: var myArray = gvSortingListagemGARs.keys; Where I have the result: [278, 279, 280, 281, 282] Who are id's of elements of a Devexpress table. Now…
-
3
votes1
answer136
viewsString array conversion
I have the following array as I turn it into a string. This string would be used to save the products from the shopping cart in Mysql. So they have various snacks and products: products 5,2,5 use…
-
3
votes1
answer265
views -
3
votes3
answers391
viewsDoubt in Arrays - Beginner
How do I make the method mostraEmpregados print on screen the name of the employees I’ve already added? How to build the array within the Enterprise class statement itself, making it every time a…
-
3
votes2
answers136
viewsProblems in the implementation of methods
I have the following classes: Door package meu.programa; public class Porta { boolean aberta; String cor; double dimensaoX; double dimensaoY; double dimensaoZ; void abre() { if (aberta == false) {…
-
3
votes1
answer96
viewsError in the calculation of values of a vector
I’m stuck in this part of my job in case two of college, the exit gets all jumbled up, for example: The profit will be -1,#$%#!@ #define vetor 40 struct Produto{ char codigo[10]; char…
-
3
votes3
answers88
viewsProblem receiving random integer values in array
Eclipse does not point out any errors in the code, but does not execute. package gerarOrganizar; import java.util.Random; public class GerarOrganizar { public static void main(String[] args) { int…
-
3
votes1
answer3965
viewsPrint vector disregarding repeated values
Make an algorithm that reads a 50-element vector and prints the vector disregarding the repeated values. The code is giving the correct output, but if I type a repeated number, the program requests…
-
3
votes2
answers1036
viewsDictionary in C always returns "word not found"
I am having problems with the code below. Although the user type a word available, the return is always palavra nao encontrada. #include <stdio.h> #include <stdbool.h> struct dicionario…
-
3
votes2
answers5853
viewsHow to decode a JSON Array on Android
The need to decode a JSON Array thus: output: [ [{ }, { }], [{ }, { }] ] I was doing it in a way that decoded a Array that way: output: [{ }, { }, { }] Code of how I was doing: Method to convert to…
-
3
votes1
answer136
viewsInsert Selected Objects into Array
I’m doing a Formula 1 racing program, my program performs reading of various race files, and creates the objects of the race. I need to deploy in this program a class that has an array to store only…
-
3
votes1
answer196
viewsHow to use Qvector<Qvector <double> as matrix?
In the mainwindow.h have: private: QVector<QVector<double> > numbers; //Variável que será minha matriz public slot: void realizar_calcs(QVector<QVector<double> >…
-
3
votes2
answers4918
viewsHow to count how many times an item repeats in an Array with unknown size?
How to count how many times an item appears in an Array I don’t know the size of? The array was created from a . CSV.
-
3
votes1
answer1018
viewsAssigning a key and a value to an object
I assign the result of an SQL query using PDO (PDO::FETCH_OBJ) a variable, and with this variable I access the values of the query as if it were an object. Example of an array as an object: <?php…
-
3
votes1
answer54
viewsWhy doesn’t inArray detect capital letters?
I don’t understand why when I look for PALAVRA the inArray() jQuery does not find it. But if I look for palavra is positive when the array is PALAVRA. The first test I expected to be positive does…
-
3
votes2
answers1144
viewsIs JSON equal to an Associative array?
Are the two the same thing? Or is JSON a more complex library or technique?
-
3
votes1
answer1040
viewsTake array values returned from another class
I need to pass the variable value sgEstado for the other class but I can’t, the value is in the return when threshing, but I can’t get the value out in the other class. ArrayList estados; try {…
-
3
votes1
answer1249
viewsHow to take objects from an array, with filter passing as parameter an object with multiple ID’s
Associating the object "categories" in "products"; With the ID I need to associate to such product, so for example "products 1" should receive the "categories" with the ID [1, 3, 4]. creating…
-
3
votes2
answers1867
viewsHow to pass an array to a Jtexfield?
I’m doing a college paper where we have to do a kind of screen login, however, with array and not Arraylist. My question is how I pass on the information from JTexfield to the array? That one array…
-
3
votes5
answers14567
viewsHow to access index from a javascript array
In giving console.log in the variable overlays, I have the following return: [Oh, 36: Oh, 37: Oh, 97: Oh, 98: Oh, 99: Oh, 100: Oh, 101: Oh] 0: Oh 36: Oh 37: Oh 97: Oh 98: Oh 99: Oh 100: Oh 101: Oh…
-
3
votes1
answer1596
viewsCheck if a value is present in a Ruby array
How do I check if a certain value is contained in a Ruby array? For example, I want to know if 'A' is present in the vector ['A','B','C'].
-
3
votes2
answers681
views"Merge" elements of a single vector
I have a vector with four elements that are numbers represented in hexadecimal form. What I need to do is concatenate these four elements (I believe that this is not the right word, but I have not…
-
3
votes3
answers2967
viewsHow to remove the last character from the last value of an array
Guys I got the following foreach: $items = ""; foreach ($_POST['termos'] as $item) { if(isset($item)){ $items = $items . $item . '+'; } } He returns to me: Array ( [0] => 1-valor+ [1] =>…
-
3
votes2
answers1263
viewsHow to create array dynamically?
I would like to create a array dynamically, I tried this way: $zt = array(); $zt = ($p_p[0] => $_p_p[1]); print_r($zt); $p_p is a array, where index 0 is the name, and index 1 is the value, 2…
-
3
votes1
answer1272
viewsHow to return the index of a matrix and its value in different variables?
I have a matrix of the following structure Matriz[indice][valor] How I return the index in one variable, and the value in another? Odd example: $indice = $matriz[indice] And for the value: $valor =…
-
3
votes1
answer903
viewsHow to go through and compare two arrays in PHP
I have two arrays that return a Mysql query. I need to compare these two results to, every time they’re different, print something on the screen. The problem is that the query coming back from the…
-
3
votes1
answer952
viewsStructure maze in C
Okay, I’d like to play a game in C "console" but I’m having a question.... Basically the idea is to have a character that advances in a maze thanks to the user, if the user writes "right" the…
-
3
votes2
answers2182
viewsRepeated elements in a matrix
I’m trying to make an algorithm that finds repeated elements in some matrix but I don’t know how. The algorithm should not check the repetition only in the rows or columns, but in the whole matrix…
-
3
votes3
answers272
viewsIncompatible types?
I am passing 3 parameters: a vector with the name of 30 cities, one with the x coordinates of the respective cities and the other with the y coordinates. I need to print on the screen the cities…
-
3
votes1
answer589
viewsSet values of an array recursively
Assuming I have the following array array( 'chave1' => 'valor1', 'chave2' => array( 'chave3' => 'valor2', 'chave4' => array( 'chave5' => 'valor3' ) )) And in this array I need to set…
-
3
votes2
answers846
viewsCount line in the matrix that have repeated numbers
I wanted to add to linhaPreta the number of lines with only 0, and the linhaBranca only with 1. public class Pixel { public static void main(String[] args) { int[][] img = { { 1, 1, 1, 1, 1, 1, 1, 1…
-
3
votes1
answer141
views -
3
votes1
answer633
views -
3
votes1
answer552
viewsPHP Mysqli Array in select html
I’m a beginner in php and I’m developing a small system for my company and that already serves as a study, because I like this area, doubt is simple, I have the code below: <?php…
-
3
votes1
answer77
viewsJquery - error accessing array
I need to compare two arrays, one with calendar days and the other with registered days. When the registered day corresponds to the property value innerHTML of the array of div he must paint the…
-
3
votes3
answers736
viewsMultiple UPDATE from a dynamic field
I’m trying to catch the ids that come by user-selected checkbox (array), and through these ids, update the table, with the following code: $ocs_imp = $_POST['check_imprime']; $contar =…
-
3
votes1
answer1861
viewsHow can I add elements to a multidimensional array?
how do I add elements to a multidimensional array. For example instead of creating a PHP array in this way: $i = 0; $aArray[$i]['title'][] = 'teste'; $aArray[$i]['link'][] = 'teste de link'; Be able…
-
3
votes2
answers230
viewsHow to convert a yaml to PHP array?
How could I do to convert data yaml in a array of PHP? Yaml example: Usuario: nome: Wallace idade: 25 linguagens: - PHP - Python - Javascript…
-
3
votes2
answers241
viewsConvert string into array along with delimiter
I am separating a string in array if there is a certain preposition in it ('com', 'for', 'por'), but I want the return of this string also containing the delimiter, ie the preposition. Using the…
-
3
votes1
answer123
viewsMethod Call with Matrix Parameters
I’ve always created vector methods using: void exemplo(int vetor[], int qtd){ // Código... // ... } And I never had problems, but I’m trying the same with matrices and I get an error void…
-
3
votes2
answers198
viewsCan I access a variable (not array) in PHP using index 0 as if it were an array?
The case is this, I have a function that if something happens it creates a array with n numbers ($x[n]) and if another happens it stores in a common variable with the same name ($x). I know I can…
-
3
votes2
answers128
viewsCreate spreadsheet by adding images and changing color of lines
This method creates an Excel spreadsheet, with int and string: public function arrayToXls($input) { // BoF $ret = pack('ssssss', 0x809, 0x8, 0x0, 0x10, 0x0, 0x0); // array_values is used to ensure…