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
answer276
viewsReturn array of integers except 0. How do I do?
The method takes two numbers per parameter, and returns one array with the odd numbers between these two numbers. public static int[] oddNumbers(int l, int r) { int odd[] = new int[r]; for(int i=0;…
-
2
votes2
answers186
viewsWhy do you accept values beyond the size of the vector?
INT vetor[3]; vetor[0] = 110; vetor[1] = 12; vetor[2] = 30; vetor[3] = 13; vetor[4] = 1; Cout << vetor[0]; Cout << vetor[1]; Cout << vetor[2]; Cout << vetor[3]; Cout <<…
-
2
votes1
answer239
viewsPHP upgrade in stock
I would like to take the amount used and whether or not the person received and update in mysql. <html> <title>Produtos da OS <?php echo $id; ?></title> <script…
-
2
votes2
answers373
viewsRemove spaces from a String array
How to remove spaces (not all spaces, just the beginning and end) from all indexes of a Java String array?
-
2
votes1
answer96
viewsInsert an array into a Key Json
I need to get a Json as follows: { "razao_social": "Loja do Zé LTDA", "nome_fantasia": "Zé Store", "tipo": "J", "observacao": "Cliente com ótimo histórico de pagamentos.", "emails": [ { "email":…
-
2
votes1
answer346
viewsArray of Boolean for Integer
How can I transform a Boolean array, boolean[] bits in his Integer correspondent? I have a function that does exactly the opposite, but I didn’t understand it enough to be able to reverse it. int…
-
2
votes0
answers38
viewsVector fill problem with typed text reading
I’m doing a little job, which consists in registering teams and matches of a football championship. When compiling and executing the code, it works, but in the part where I will register, it jumps…
-
2
votes3
answers818
views -
2
votes2
answers51
viewsHow to inform data in a vector
I’m not getting to report 10 student grades. import java.util.Scanner; public class exer { public static void main(String[] args){ Scanner scn = new Scanner(System.in); double[] N = new double[10];…
-
2
votes2
answers1825
viewsIncrement variable within a foreach
How do I make a variable increment within a foreach? foreach($adults as $adultos): $i = 1; echo "<strong>Quarto".$i++."</strong><br>"; echo "Adultos:".$adultos."<br>";…
-
2
votes2
answers161
viewsHow to insert the elements of the X array into an index of the Y array?
I own the array y where in your index 0 holds the values App and Views array (size=1) 0 => array (size=2) 0 => string 'App' (length=3) 1 => string 'Views' (length=5) In the x I have a array…
-
2
votes3
answers391
viewsInsert multiple mysql checkbox records
are trying to enter in the database information of multiple checkbox at once , for example a news is related to more than one category then and only select the categories and save , however this…
-
2
votes2
answers356
viewsTake any variable from an array that has a certain id in Angularjs
With the following code, I am saying that in the second array contained in the object $scope.listademercadoria there is the property "quantity", and I am declaring it as value 0.…
-
2
votes1
answer97
viewsCompare a string array with another string array and create a new array
I need a method/algorithm to find in array1 strings of array2 and create a new array (array3) with all Stings separated from array2. For example array1 = ['azxsdfghjkazxfgtfgt']; To array2 would…
-
2
votes1
answer401
viewsPrint de array php
Nice afternoon to everyone!!! : D I am creating a php page that informs me my local ip, I am doing this through the command: shell_exec('ipconfig') so far so good because it returns the ip of my…
-
2
votes2
answers116
viewsWord problem with same letters
I’m solving a problem where I get one array of strings with different words, I have to find out for each word (string) which are your friends. Friendly words are those that have the same letters in…
-
2
votes1
answer350
viewsProblem in C language, issue with prime numbers
I am solving exercises, in C language, on vectors. The exercise is as follows: Make an algorithm that uses a menu with the following options: sort an ascending 5-position vector, sort a descending…
-
2
votes1
answer29
viewsSearching Array of variables via Ajax and inserting in their due inputs of a form
I have a form that searches and fills, via ajax, the name of the person and year of birth (in their respective fields), all this from the Cpf typed by the user. It’s something like this: Digite o…
-
2
votes2
answers80
viewsIs it possible to use Heredoc with special characters in an array?
I have a multidimensional array, as the example below shows, but I wonder, if I can use a Heredoc on it, would it be possible? I could include special characters not escaped, if it is possible to…
-
2
votes1
answer709
viewsHow to replace values with NA using element encoding (not position)?
I’m having trouble replacing values on a vector with NA, but using treatment coding (not position). A simple and hypothetical example of my problem is (my data set is too large and I have several…
-
2
votes1
answer39
viewsValue of one of the array fields
I need to check the value of one of the fields of a array but I’m not getting it. var_dump($array_exemplo); array(1) { [0]=> array(3) { ["primeiro"]=> string(1) "1" ["segundo"]=> string(1)…
-
2
votes3
answers142
viewsHelp with java arrays
I have the discipline array and the current array. The current one is an exact copy of the disciplines. If there are two equal Strings within the disciplines array I need to delete all the same and…
-
2
votes3
answers232
viewsFilter array value
My array will be: $arr = array(); while($r = mssql_fetch_assoc($query)) { $arr = array('cnpj' => $r['cnpj'], 'empresa' => $r['nome']); } In while, there are several results (repeated CNPJ),…
-
2
votes1
answer95
viewsHow to insert a file into an array
I’m having a hard time and I couldn’t fix it. I have a settings file in this file I have an array and several arrays within it and one of these is my route array. What I need to do is include a file…
-
2
votes2
answers1067
views -
2
votes2
answers127
viewsJavascript does not take changed array before click
I have a click code: var layerMap = []; $(document).on('click', '#TipoMapa', function(){ console.log(layerMap); }); And I have a code that changes the variable layerMap: $(document).on('click',…
-
2
votes1
answer531
viewsMultidimensional array from mysql query
Good afternoon, I have a system, with the following tables : pagina: id,nome ,icone, idGrupo. paginaGrupo: id,nome,icone, idGrupoUser. I’m setting up a dynamic menu on top of these tables. I take…
-
2
votes2
answers190
viewsWhy is it possible to change constant values in Javascript arrays?
Having the following code: const arr = [1,2,3]; console.log(arr); arr.push(4); console.log(arr); arr.pop(); console.log(arr); arr shouldn’t it be constant? And therefore shouldn’t accept the method…
-
2
votes1
answer100
viewsCapture only one element of an array
I got the following array, how could I store in a new array only the "producto_id" of all "loja_id"? array(2) { [0]=> array(2) { ["loja_id"]=> string(3) "286" [0]=> array(2) {…
-
2
votes1
answer497
viewsDoubt about JS objects with array
I’m wondering how to make an object that has an array inside, I don’t even know if that’s possible, but it follows more or less what I want to do: var produtos =[ { nome: "Sei lá", cor: azul,…
-
2
votes1
answer1101
viewsMaximum possible size to allocate a vector
Guys, I have a data structure project that’s meant to analyze search algorithms on the largest possible vector that my machine can allocate. Can someone help me figure out how to create a vector of…
-
2
votes1
answer396
viewsVector and matrix ordering
Do you have another method to sort vector/matrix in ascending or descending order other than the one I used ? ( What would you change in this code to make it " better " ? ) #include <stdio.h>…
-
2
votes1
answer153
viewsSearch Array() in variable and database
I have the following fields in Array(): # Tratamento das variaveis para substituição da mensagem $campos = array( 0 => '#celular', 1 => '#ddd', 2 => '#cpf_cnpj', 3 =>…
-
2
votes3
answers88
viewsInsert non-existent months into the array
I’m putting in a array total sales value per month. The code is working perfectly, but I need the javascript check which months are not in this array and fill it in order 1 to 12. For example: The…
-
2
votes1
answer56
viewsHow to save in a single vector, base and derivative classes?
I have a work in C++, and I need to write to a single vector, a base class, and two derivatives. How to do this vector?
-
2
votes0
answers49
viewsMy array is not returning, if you do not select a previous value
Guys, I’m doing a "lot your pc" and there are some things that are optional and if you do not select a previous one, it does not bring me the value of the remaining. Example: Cabinet Motherboard…
-
2
votes1
answer2383
viewsHow to sort two vectors (ascending order ) into a third vector using only one loop?
My teacher posed this problem and I’m not able to sort in ascending order just by using a loop to sort. #include<stdio.h> main(){ int i,a[5]={1,4,8,9,11},b[5]={3,6,7,10,15},c[10];…
-
2
votes1
answer1930
viewsPhp array check for values or keys
[TotalPed] => Array ( [VlrTotalIPI] => 0.00 [VlrTotalItens] => 652.68 [VlrTotalDesc] => 0.00 [VlrTotalPed] => 652.68 [PercComPed] => 0.00 [PercComPed2] => 0.00 [VlrFrete] =>…
-
2
votes2
answers886
viewscompare and remove repeated element
I have this array of objects, and I would like to scroll through and remove the repeated author by name, but I cannot. public class Pessoa { private Autor autor[]; int cont = 0; public Pessoa(Autor…
-
2
votes3
answers687
viewsHow to join values in common php array?
I have the array $vetor[0]['codigo'] = '1'; $vetor[0]['valor'] = '4'; $vetor[1]['codigo'] = '1'; $vetor[1]['valor'] = '2'; $vetor[2]['codigo'] = '2'; $vetor[2]['valor'] = '2'; I need to merge all…
-
2
votes1
answer208
viewsHow to declare a multidimensional array using new
How do I declare a multidimensional array using new ? A normal array would look like this: int* ponteiro = new int[5]; But int* ponteiro = new int[5][5]; does not compile ! but int array[5][5];…
-
2
votes1
answer56
viewsModify Array() HTML form result
I have the following return of Array(): [item] => Array ( [data_vencimento] => Array ( [0] => 2016-12-05 [1] => 2016-12-07 [2] => 2016-12-22 ) [itens] => Array ( [0] => 150,00|1…
-
2
votes2
answers159
viewsInversion of array (positions)
I’m trying to do an array inversion in the language C. For example: I have an array [1, 2, 3], I need to invert the numbers in the SAME array, giving an output like this: [3,2,1]. I’m trying, but…
-
2
votes1
answer1069
viewsHow to access variables from another class of objects per array?
I have two classes, : Route and Costs. Route : public double getKmPercorrida() { return kmPercorrida; } public void setKmPercorrida(double kmPercorrida) { this.kmPercorrida = kmPercorrida; } public…
-
2
votes1
answer318
viewsRemove indexes from the array
How to remove indexes from an array? Original array ["Torrada" => 4,"Cachorro quente" => 1] for [4,1]
-
2
votes1
answer400
viewsTransform Array and String
How to transform an array similar to this and Strings to write each line in the Mysql database. I will only need the data of each array ( date, site and Status ) print_r($arrayOut); Array ( [1]…
-
2
votes2
answers243
viewsHow to add variable to [JS] array
I have the following code: var newLat = markerElem.getAttribute('lat'); var newLng = markerElem.getAttribute('lng'); var locations = [ {lat: newLat, lng: newLng} ] I want to take the values of the…
-
2
votes2
answers120
viewsHow to format strings and store them in a dynamic vector
In several parts of my code I need to use bash commands to run programs on Ubuntu. To do this, format the command using sprintf and then run with the system function. Ex: sprintf(sprintfoutput,…
-
2
votes2
answers91
viewsJoin in array creating elements?
We can imagine the following array: var arr = ["a", "b", "c", "d"]; I know I can use the join(", ") to turn it into a type string: "a, b, c, d", but I would like to create an element for each item…
-
2
votes1
answer288
viewsProblem with login system - array
Hello. I am creating a login system for study purposes. I identified in the file that is not populating the array with the database information... and yes, I have already made sure that the email…