Most voted "multidimensional-array" questions
Multidimensional arrays are data structures that store values in more than one dimension. In other words, a multidimensional array is like a container that will hold more values for each position, that is, as if the array elements were in turn other arrays.
Learn more…138 questions
Sort by count of
-
11
votes3
answers1814
viewsSort a multidimensional array with numerical values
Suppose the following situation in which I have a array composed of several array numerically valued: $array = array( array(22, 25, 28), array(22), array(22, 23) ) I’d like to leave this array…
php array algorithm multidimensional-array classificationasked 10 years, 9 months ago Douglas Cabral 345 -
6
votes3
answers5927
viewsGroup values from an array in PHP
I have a grid form that returns the following values within an Array: array (size=3) 0 => array (size=5) 'pei_seq' => int 0 'prg_cod_barra' => string '7899619704729' (length=13)…
-
6
votes3
answers878
viewssort multidimensional array php
I have the following array returned from a webservice (in the image I identify what I want, below the text for copy): Array ( [DataTable] => Array ( [ID] => STOCK [Line] => Array ( [0]…
-
4
votes3
answers3696
viewsMerge arrays in php
Someone knows something that turns it: $name = [0=>'name1',1=>'name2']; $email = [0=>'email1',1=> 'email2']; in this? $data = [ 0 => ['name'=>'name1', 'email'=>'email1'], 1…
-
4
votes4
answers7700
viewsSort a multidimensional array by a column, keeping the same lines of the array
I have an array with two columns, where in the first column I have the name of a station, and in the second I have the address of the same. I need to sort this array alphabetically by station name,…
-
4
votes3
answers240
viewsWorking with X-layer array in JS
I have a big problem, I have researched several places and I have not found the solution I hope you can help me... My goal is to create a JS function that will take an array as a base, which here I…
javascript jquery array multidimensional-array dynamic-programmingasked 9 years, 4 months ago MateusFMello 166 -
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
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
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
votes3
answers270
viewsSimplifying an Array - PHP
I have a multidimensional array where the data lies as follows: Array ( [0] => Array ( [0] => Array ( [0] => Brasil [1] => Franca [2] => Italia [3] => China ) ) ) I would like a…
-
3
votes3
answers468
viewsSearch for word in the first array column
How do I search for a word in all lines, but only in the first column of a array that will always increase in size? string[,] array = new string[1,6]{{"texto","","","","",""}};…
-
3
votes1
answer354
viewsHow to sum array data in json specified by date
array(10) { [0]=> array(4) { ["data"]=> string(10) "01/11/2015" ["valor"]=> int(50) ["intensidade"]=> float(37.5) ["carga"]=> int(35) } [1]=> array(4) { ["data"]=> string(10)…
-
3
votes1
answer88
viewsMount a two-dimensional array from another array
I have the array $dados down below: array(5) { [0]=> "2018-03-28" [1]=> "jantar" [2]=> "lanche" [3]=> "2018-03-29" [4]=> "lanche" } From this array, how could I mount another…
-
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
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
votes2
answers460
viewsRecursive or loop method to popular or list an n-dimensional array
I’m trying to build a method capable of filling an n-dimensional matrix in all positions, for example: I have a 2-dimensional matrix, where this matrix is 2x2 with only 2 dimensions in a Cartesian…
-
3
votes2
answers639
viewsGenerate random numbers in 2d numpy array without repeating Python
Good afternoon, I’m trying to generate a 2d numpy array without repeating numbers. My code: TAMANHO = 4 tabela= np.zeros((TAMANHO, TAMANHO), dtype = int) tabela[:, 0] = np.random.randint(1, 170,…
-
2
votes2
answers706
viewsPrint highlighted matrix specific values
In my studies here with matrices I’m trying to highlight only the odd values (leave in bold), but I don’t understand how to do this. Below follows what I did, but I am printing both the numbers in…
-
2
votes1
answer176
viewsProfundidade Array
I have an a1 Array a1=[a2[a3[a4[]],a5]] I need to know the depth of the array now in this case is 3 because inside the a1 array has the a2 array and inside the a2 has the A3 and inside the A3 has…
-
2
votes2
answers220
viewsIs there a function to reindexe a multidimensional array?
Guys, in need of help, I have a function that returns the following array: Array ( [0] => Array ( [0] => valor1 [2] => valor2 ) [1] => Array ( [0] => valor3 [1] => valor4 [3] =>…
-
2
votes2
answers241
viewsOrdering of all elements of a multidimensional array (array)
I need to sort the array below in alphabetical order using the numeric key: Array ( [AM] => Array ( [1] => Array ( [localidade] => Arena da Amazonia [cidade] => MANAUS [estado] =>…
-
2
votes1
answer101
viewsHow to remove the red part of the figure?
require("setup_do_banco.php"); $colunas = $pdo->prepare("SELECT * FROM origem WHERE ativado = 1"); $colunas->execute(); while ( $coluna = $colunas->fetchAll(PDO::FETCH_ASSOC) ) {…
-
2
votes1
answer395
viewsSplit two-dimensional array into 2 simple arrays - PHP
I am making adaptations in an old system and need to create a new routine to split a two-dimensional array into 2 simple arrays. Let’s say the variable $query get the array below: $query =…
-
2
votes1
answer4783
viewsremove duplicate values in multidimensional array
I have a huge multidimensional array and need to remove duplicate values with PHP or some function that does this when using Cakephp. Array structure: Array ( [0] => Array ( [Advertencia] =>…
-
2
votes1
answer76
viewsHow to simulate this PHP function in jQuery?
The function below made in PHP will return me an array where the searched word fits, as I can do the same though with jQuery? $meuArrayMultidimensional = array(array("campo" => "teste"),…
-
2
votes1
answer1278
viewsHow to rotate an array (array) in Java?
I have a two-dimensional array, of size M x N, that stores Tiles of a map, in the following format: [1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12] And I want to rotate 90º (e.g., turn the map so that…
-
2
votes2
answers402
viewsHow to mount this multidimensional array via foreach
I’ll just put the part where I’m having trouble! The array that I need, needs to be in this format. Example 1: Array ( [atributos] => Array ( [atributo] => Array ( [nome] => Tamanho [valor]…
-
2
votes1
answer100
viewsCreate a 2D vector from a 1D vector in Python
I have a vector with the following values: a = [10, 20, 30, 40, 50, 60, 70, 80] I need to create 2D vector with these values. For example, it would have to look like this: b = [[10, 20], [30, 40],…
-
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
votes3
answers1110
viewsMultidimensional array of different types
I have a view in my application database where I account for the user’s name, his sector and the total number of records issued (another table’s count): Table(View) Totalporusuario Columns:…
-
2
votes1
answer722
viewsAdd values within the Two-Dimensional Matrix from the line the user chooses
In the exercise I had to create a two-dimensional matrix and then when the user typed 0, 1 or 2 to know the matrix line, I should add the line values and show the result. I wonder if inside the…
-
2
votes2
answers47
viewsHow to access the data in a variable of type double[ , ] in C#
I’m studying C# and in a certain code I came across the following situation: double[,,] R = new double[_StatesMaxCount, 3, 2]; In all the time I’ve been studying, I’ve never seen this kind of…
-
2
votes2
answers110
viewsDoubt using array
I would like to know why the index is used in the code 0 when a for to identify if the size of the array is smaller than the counter j. public class Aplicacao { public static void main(String[]…
-
2
votes1
answer50
viewsIndex 3D arrays with Numpy
I have an array in three dimensions (x, y and z) and an address vector. This vector has a size equal to the x dimension of the array, and its objective is for each x to point a y bringing their…
-
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
answer6137
viewsHow to access an item in an object array?
I’m taking information from the database and putting it into an array: (more details of the code) var alunos = {}; var self = 0; function sortearAluno(){ var dataForm = {'tipo': "listar"}; $.ajax({…
-
2
votes2
answers220
viewsJquery problem in handling ajax data coming as array
My array returns from php like this (post): Array ( [0] => Array ( [O email digitado é invalido! Por favor insira um email correto.] => 1 ) [1] => Array ( [O telefone digitado está num…
-
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…
-
2
votes1
answer864
viewsAccess information in Multidimensional Associative array (PHP)?
I have the following structure: $arrDados = Array ( [0] => Array ( [NumeroEmpenhoNumero] => Array ( [type] => NULL [size] => 0 [deci] => 0 [code] => 0 ) ) [1] => Array (…
-
2
votes2
answers454
viewsInserting index and value into a two-dimensional array
I have a two-dimensional array (it contains data from the database). To go through this data, I use a foreach(). I need to add an index and a value to that index at the end of each foreach…
-
2
votes1
answer63
viewsrecover a client name in a multidimensional array
I am creating a script to execute procedures in the database of some customers, I have the following arrays with the credentials of each: $hosts["Cliente1"] = array("ip"=> "ip_do_cliente",…
-
2
votes1
answer55
viewsKeys in PHP Array
I have a very stupid doubt, I was able to identify the problem, but I could not solve it. hahahaha So here’s the thing... I have the following array: array:7 [▼ 1 => array:5 [▶] 2 => array:5…
-
2
votes1
answer726
viewsData returned in an array is duplicated
I am running a SELECT in the database through a function and returning the result as a multidimensional array, where each primary index refers to a record, and the secondary indices are the database…
-
2
votes0
answers231
viewsConversion from array to two-dimensional array using parameter
I have a question regarding the conversion of vectors (array) to two-dimensional vectors. I need to read a string and separate the columns when a blank is found. I did this using the method split()…
-
2
votes1
answer229
viewsPython Multidimensional Array Problem
Basically my algorithm imports all the photos I have inside a directory (dataset_train), saving these photos in vector X and the name of the folder where it was in vector Y. import os import cv2…
python array image-processing multidimensional-arrayasked 5 years, 5 months ago Felipe Ricardo dos Santos 46 -
2
votes1
answer88
viewsIncrease multidimensional array size at runtime
Problem: I maintain a 2D multidimensional array that has a dynamic size, is always growing, as I am not allowed to use vector I need to develop a strategy to increase the size of this array at…
-
1
votes2
answers452
viewsHow to make the return of a query (PDO) bring me an array already?
I have that I have : Periodo | Cliente _________________________ jan2014 | Cliente A jan2014 | Cliente B The one I want : array( 'jan2014' => array( 0 => 'Cliente A', 1 => 'Cliente B', ) )…
-
1
votes2
answers703
viewsSelect an array based on the value of an internal key
I have the following array: Array ( [ajax.js] => Array ( [name] => ajax [fileName] => Web/js/App/ajax.js [file] => ajax.js [path] => Web/js/App [parent_path] => App [extension]…
-
1
votes1
answer65
viewsResize Multidimensional/Associative Array from a Resultset
I’m trying to feed a array multidimensional and associative from a Resultset, but accuses the following error: Microsoft VBScript compilation error '800a0401' Expected end of statement…
-
1
votes1
answer322
viewsNesting keys of an array in a Javascript object
How to create a nested javascript object from a literal array? I have the following array: var x = ['a','b','c']; From the array 'x' I would like to generate the following object: var y =…