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
answer42
viewsReturn Ids searching for the value of a multidimensional array
Is there any way without using foreach, using only native PHP functions to return an array with ids searching everyone with value 'a' ? Example: $lista = array( array( 'id' => '100', 'name' =>…
-
0
votes1
answer120
viewsUsing a pointer can make my code faster?
I was told that if I work using pointers the program will be faster. If instead of using index to traverse a vector I use the pointer, it looks better?
-
0
votes2
answers5464
viewsSegmentation failure: Recorded core image
I made a code in C to find the smallest value and position of it in a vector x[N]. Every time I compile the program by terminal (Linux), it accuses the following message: Segmentation failure…
-
0
votes1
answer56
views -
0
votes3
answers82
viewsError while traversing vector
The user pastes the values that will be saved within the array and then displays these values. However, the following error is occurring: An unhandled Exception of type…
-
0
votes1
answer788
viewsHow to compare all values of an array with a variable
I wonder if it is possible for me to have an array with multiple dates and to know if another date is larger than all the dates within the array. For example: Date[] datas =…
-
0
votes1
answer44
viewsJoin two array in php
Good morning guys, a quick question. I need to merge two array of a queries in the following way: $tamanhos = array('p', 'm', 'g'); $valor_item = array('10', '20', '30'); where "p" has to be equal…
-
0
votes2
answers1053
viewsHow to fill a list C#
I need an appeal similar to the one made below: email ListaEmail = new email(); … while … { email Email = new email(); Email.email1 = adoDR["email"].ToString(); Email.tipo =…
-
0
votes2
answers180
viewsError while running program using "args"
I am trying to run a program passing some values as parameters on the command line but is returning the error below. C:\Users\joao.mello\Documents\C#> .\exercicio32.exe 5 1 0 4 9 32 4 Unhandled…
-
0
votes1
answer100
viewsAlgorithm of Division and Conquest
I’m having trouble making a division and conquest algorithm of the sum of the elements of an arrangement. public static int somatorio(int[] a, int numElem) { if(numElem == 0) { return 0; }else…
-
0
votes1
answer182
viewsIdentify number in array and change to a string
I’m trying to trade divisible numbers for 3 for a word inside my array. I tried to add my if within the array and with no result. def code( n ) if n % 3 == 0 Array.new(n + 1) { |i| i } end…
-
0
votes2
answers1828
viewsHow to make a draw of words and letters by clicking the start button?
Can someone help me? So I need to do a draw of words that are in the Array and a draw of the lavras of these words, every time the user clicks the start button, that is in the table. Thank you in…
-
0
votes2
answers75
viewsWithdraw repeated
I have the following code: var e = Array (10,20,30,40, 50); for (i = 0; i <= 50; i++) { for (j = 0; j < e.length; j++) { if (i == e[j]) document.write ("O numero escolhido é: " + i + "<br…
-
0
votes1
answer128
viewsUse PHP array and bring results in multiple rows
I have an array $_POST['form']['clima'] that in this example has the value below array(2){ [0]=> string(1) "1" [1]=> string(1) "2" } I need to take these values to join with $id (in this…
-
0
votes3
answers1185
viewsHow to insert a new value into an array without duplicating through the switch case?
One of my attempts so far has been: array = [1, 2, 4, 5]; definir = function() { switch (array) { case (array > 1): array.push(1); break; case (array > 2): array.push(2); break; case (array…
-
0
votes0
answers60
viewsRange of a SWIFT Array
I have an array of bytes and I need to find out in which track (startindex and endindex) a byte this or if only has startindex ex: var Faixa1:Array<UInt16> = [2,4,6,8,10,11,12] var…
-
0
votes3
answers374
viewsTransform string into json
I’m having a hard time converting string {data} in Json, I get her separated by comma several times, I’d like to turn her into Json to collect the first key var data = [ "$SP", "92", "00:01:36.340",…
-
0
votes1
answer270
viewsHow to make calculations with elements of a Ruby array?
numeros = [1, 2] class C def calcule_array(*numeros) puts a + b end end numeros = C.new puts numeros I would like to know how to make calculations with whole elements that are inside an array in…
-
0
votes1
answer63
viewsSlice an array
I’m having trouble with x2 values when trying to slice to display in graph 2 does not appear anything and I can’t see where I am missing? import matplotlib.pyplot as plt import numpy as np xold =…
-
0
votes2
answers278
viewsAssign multiple array to a variable dynamically
Hello, I need to assign several array to a single variable, their value will all be in sequence in this variable. Ex.: $variavel = $array[0] . $array[1] . $array[2] . $array[3] . $array[4]; echo…
-
0
votes0
answers36
viewsChanging the names of XML nodes and subnodes coming from an array
I have an array, which I want to transform into an xml document, I already managed to create it but I can’t change the names of some nodes and subnodes, follows an example of an array to be…
-
0
votes1
answer23
viewsGenerate array with substring positions
There’s some way I can pick up a string, like, "John went to the bar last night". Generate an array that stores the position of all " of that string. I will use this to put in these positions for…
-
0
votes1
answer720
viewsPass array as parameter for web api in php with Angularjs
In my local environment I use PHP7 and developed Restful API for an application that uses Angujarjs. I needed to make a get request to the Api and pass an array as parameter and did so…
-
0
votes1
answer568
viewsI am unable to pass one vector per parameter in C
I am trying to pass a vector per parameter to a function in C, but I am going through difficulties. #include <stdio.h> #include <stdlib.h> #include <math.h> void calculafx( x2,…
-
0
votes1
answer546
viewsMinimum value of each Python array column
import numpy as np X = np.random.rand(4,3) print("X: \n", X) XMin = np.zeros((1,3), dtype=np.float64) for j in range(3): print("X[{0}]: {1}".format(j,X[j])) minimo = np.amin(X[j]) print("minimo: ",…
-
0
votes1
answer2214
viewsHow to add values within an array?
I have an integer value and need to transform it into an array to sum each of the elements individually. I did it as follows (example): int n = 1230; string sn = Convert.ToString(n); //converte em…
-
0
votes1
answer41
viewsProblems accessing struct members
I have to do some functions with these structs, but since Agenda has a contact struct array and in each contact has another data struct, how do I access the fields? Do I have to work each struct…
-
0
votes3
answers163
viewsOperator "!=" does not work in my code?
I have a part of my program that I do several checks when the button is clicked and one of these checks is: it picks the value inserted in textboxRankTecnica and has to buy with the array…
-
0
votes1
answer153
viewsWhat is the split method in Ionic for?
Well, I’m developing an app with Ionic 3, and I hear about a method called split, but I never understood its functionality. I just understood that it is related to arrays. Faced with this : What is…
-
0
votes1
answer186
viewsMount a result array of a php foreach
Hello! I am unable to mount an array with results from a foreach. Got and foreach foreach($Result as $Aluno): extract($Aluno); echo '<tr>'; echo "<td class='nome'>{$Nome}</td>";…
-
0
votes1
answer38
viewsRemove Whitespace in Array
Well, I’m developing an app with Ionic 3. When I try to record some data in the array, it appears " n" at the beginning and end of the array. Follow the code : element = this.pedido.produto; if…
-
0
votes2
answers441
viewsUse the result of an array as value of an Insert - PHP
Good night, I’m having a doubt. I am uploading a file and extracting its contents and inserting in my database, but I have a question how to use the array like the value My file consists of a…
-
0
votes2
answers883
viewsBrowse variable type php array
I have a $array variable that contains array values that were received from a JSON.stringify(venc) [ {"Nº da Parc":"1","Data do pagamento":"06/04/2017","valor a pagar":"R$ 50,00"}, {"Nº da…
-
0
votes3
answers400
viewsMake a Static method in the main class that writes on the screen all even numbers from 1 to 10000 that are palindromes
This is my method: public static void B() { int vet[]=new int [100]; int vet2[]=new int [vet.length/2]; for(int i=0;i<=vet.length;i++) { vet[i]=i+1; } for(int i=0;i<vet.length;i++) { int rest…
-
0
votes1
answer174
viewsHow does "array.Sort()" work?
How does the array.sort((a, b) => a - b) ? Why is this symbol =>, and why this operation a - b Are you subtracting the elements? That doesn’t make sense to me.…
-
0
votes1
answer323
viewsJava Array List: How to show a Jlist the values and Positions of the String Array
I made this code in class: public class Dados { ArrayList<Contato> contatos = new ArrayList(); public void cadastraContato(Contato contato){ contatos.add(contato); } public String…
-
0
votes1
answer242
viewsQuery with array returning only first record
I have the following querys: <?php $VarMensagem = 1; $pdo = new PDO($dsn, $un, $pwd, $opt); $data = array(); $dataGeral = array(); try { $stmt = $pdo->query("SELECT * FROM mensagem WHERE…
-
0
votes1
answer111
viewsHow to relate 2 arrays (array1 is name and array2 is ID) and bring the corresponding value
I have 2 arrays, where one is an array with the names and the other is an array with the ids. I need that according to the name of the string (which it contains in the $name array), it searches in…
-
0
votes1
answer266
viewsTwo-dimensional array size is not being defined
I created a matrix and put it to initialize with the values passed in the constructor, but it is not initializing. I created the object, played the values, but when I call the method to show the…
-
0
votes1
answer24
viewsTrasnformar array in Divs?
I have a page php who brings me a registration list, but he brings a array and would like every item of it to come in divs or table with rows. Down with what I’m doing: $db = JFactory::getDbo();…
-
0
votes1
answer164
viewsHow to clone array
I’m wandering about on a way to make sure that as all elements of the array in question, go all over again. See this my source code below: Code <html> <body> <button…
-
0
votes3
answers127
viewsHow to clear a list without losing all positions?
In my application in C#, I have a list List< float> where I store data arriving through serial port. With the execution of the application in progress this list begins to get huge. I am not…
-
0
votes2
answers222
viewsError showing return of json array in php
Error: Notice: Trying to get Property of non-object in C: xampp htdocs json get_json.php on line 6 My php code: <?php $get =…
-
0
votes1
answer31
viewsrecover rows from a data frame
I need to recover the entire line of the DF, in a new DF, only when I find the vector element, in the id field of the DF ids <- c(2001586,2007037,2012677,2020645) df <- t(data.frame(colnames =…
-
0
votes1
answer36
viewsHow to access the array in an extended Javascript function
Hello, I’m doing a class extension Array where I want to create a method that checks whether a property exists within the Array: thus: Array.prototype.contains = function(element){ for(let e of…
-
0
votes1
answer54
viewsPerformance between index() and hashmap . get()
I’m having a performance issue with my application and I’m thinking it might be the various .get() that I give, this way I’m considering transforming these hashmaps for arrays and use the indexOf()…
-
0
votes1
answer65
viewsCalculating Random Password using Arraylist and Resultset in Java
Good morning, I have a question, I need to calculate a new password for each Patient when going through this method: ps = getConexao().prepareStatement(SQL_VERIFICAR_PROTOCOLOS_PENDENTES);…
-
0
votes1
answer27
viewsChanging object value inserted in an array
Take a look at this example: https://jsfiddle.net/b4w6jqgf/1/ In it I have two arrays: __options e __defaultOptions; When starting push __options by inserting the __defaultOptions object. Later I…
-
0
votes0
answers55
viewsForce array to have all widgets in string
$values_x = array(); for ($i = 0; $i < count( $series[0]['data'] ); $i++ ) { $values_x[] = $series[0]['data'][$i][0]; } $values_y = array(); for ($i = 0; $i < count( $series[0]['data'] ); $i++…
-
0
votes1
answer248
viewsList empty after python loop
Hello, I have the following code that does this: It will traverse a vector that has a certain set of elements (residuo) with the same ID ([1][1][1][2][2] for example) and then store all elements of…