Questions tagged as 'array'

1
answer

In which part of the application is it most appropriate to reorder an array (database, server application, client code)?

Let's suppose that in a MYSQL database query, I need to pick up the last 1000 data that was posted, but within those results, the order must be growing (not descending, as would happen in ORDER BY ID DESC Limit 1000 ). The response of...
asked by 16.10.2014 / 13:41
3
answers

Error listing items in an array with foreach ()

I have array with the list of several Brazilian banks and I need to get the name of the bank where the code of it is passed according to what it has in the user's account, but when doing this search for the code it r...
asked by 28.12.2015 / 18:52
2
answers

Add the 5 largest values to an array

I have the following method: public static void topFiveSales(int idEmpresa) { List < Entidade > allList = Entidade.findByEmpresa(idEmpresa); float totalVendasByEntidade; Float[] totais = new Float[5]; for (Entidade ent:...
asked by 30.07.2015 / 16:55
1
answer

What is the difference between array_walk and array_map?

In PHP, we have two functions that run through the array and apply a given function to each element: array_walk and array_map. Example: $meu_array = array(1, 2, 3); $callback = function ($value) { return $value * 2; }; $novo_array =...
asked by 28.07.2015 / 17:48
2
answers

SQL query with array type in PostgreSQL

How to filter this field of type array in PostgreSQL? I have a X table with a Y field of type character varying[] with two records: {'meeting','lunch','training','presentation'} {'breakfast','consulting', 'meeting'}...
asked by 12.08.2015 / 16:07
1
answer

Matrix Ordering with Values Exchange

Good afternoon! I mounted an array that receives 9 records from a single variable and the values are displayed on the user's screen. However, when trying to put this array in ascending order, I tried to use the value exchange method, but at the t...
asked by 11.12.2018 / 22:03
1
answer

How to access the indexes of a very large vector in C?

I have a problem that I have to mount a vector ( vet2[50] ) with the sum of a large vector ( vet1[100] ), this vector vet1 is provided by the user and the sum is given by: vet2[0]=vet1[0]+vet1[1] vet2[1]=vet1[2]+vet1[3] . ....
asked by 09.10.2016 / 16:01
1
answer

Is there a way to do these assignments more cleanly?

I have a class that should be started with a% of properties. $subscription = new CheckRenew([ 'custom_2_id' => 13, 'email' => '[email protected]', 'zip' => '90530000', 'number' => '1234' ]);...
asked by 29.12.2016 / 20:04
2
answers

How can I format this array the way I want it?

I am creating a Seeder for Laravel insert values into a N para N table. I'm setting up array in one way, but I need it to become "in another" in the end. This is because I want to avoid constant code repetition (re...
asked by 26.04.2016 / 16:01
1
answer

Why Arrays implements IEnumerable but does not implement IEnumerableT?

I was making a class that contains an Array of class Episode : public Episode[] EpisodesList; Then I implemented IEnumerable<T> in my class. And as expected, I implemented the method GetEnumerator() ... p...
asked by 15.04.2015 / 06:57