Questions tagged as 'array'

1
answer

Delete repetitions within the While

I have a search that takes the 3 most relevant results in my DB, and then I separate the categories of those 3 results into an array within a While, so it looks something like: while($x = $x->fetch()){ $array = explode(',', $x["categoria...
asked by 11.10.2016 / 19:31
1
answer

What's the difference between using ArrayIterator vs Simple Array?

Some examples on the net with ArrayInterator are used in the following ways: $arr = array("Banana", "Abacaxi", "Abacate", "Morango"); // loop through the object foreach (new ArrayIterator($arr) as $key => $value) { echo $key...
asked by 24.09.2016 / 07:08
2
answers

How do I access the indexes of a vector returned by a method in java?

I have a method called vetorVoos that returns a vector of type NodeVoo and I want to access the contents of that vector through the method in another class. This is the method: public NodeVoo[] vetorVoos(){ if(isEmpty()){...
asked by 04.05.2014 / 01:03
1
answer

Print combinations of integers in ascending order

"Given two nonnegative integer numbers m and n, generate all m-size combinations of integers from 0 to n-1, in ascending order. Example: m = 3 and n = 5 (0 1 2); (0 1 3); (0 1 4); (0 2 3); (0 2 4); (0 3 4); (12); (1 2 4); (1 3 4); (2 3 4)...
asked by 23.11.2014 / 20:39
3
answers

Get the first and last date of an array

In PHP I have this array: $locados = array('2016-01-01', '2016-01-02', '2016-01-03', '2016-01-06', '2016-01-07', '2016-01-08'); These dates within the array represent two different apartment rentals: Rent 1: 2016-01-01 until 2016-01-03...
asked by 29.10.2015 / 21:06
2
answers

Calculate minimum number of permutations to sort

I received this question in a test, and I would like to know which paths to take. I have an array of n distinct integers, A = [a0, a1, ..., an-1]. I can exchange any two array elements any number of times. How to calculate the smallest number...
asked by 15.03.2017 / 02:17
3
answers

Notice: Array to String conversion in

I have a problem with the following code: <select name="tipoPessoa" class="form-control"> <?php $tipos = array("Pessoa Fisica","Pessoa Juridica"); $tipoSemEspaco = str_replace(" ","",$tipos); foreach ($ti...
asked by 13.03.2017 / 04:49
1
answer

Format values from one array to another

I have a CSV which returns me the following array: Array ( [0] => Array ( [0] => ANO [1] => Sciences [2] => Mechanics [3] => Telecom ) [1] => Array...
asked by 20.03.2017 / 20:43
1
answer

How to create random invertible arrays in R

One of the ways to find the estimator using the ordinary least squares method is by generating random matrices, given by the formula: B = (X’ X)^-1 X’Y Where Y = a+bx+cw+u , being x and w random vectors of size 100...
asked by 23.03.2014 / 15:46
6
answers

What's the difference between declaring an array with "array ()" and "[]" in JavaScript?

In JavaScript we can declare an array in two ways: var matriz = new Array(); and var matriz = []; What is the difference between the two and what are their consequences? This question is being posed for the purpose of documenting...
asked by 04.03.2014 / 21:48