Questions tagged as 'foreach'

3
answers

How to know if I am in the last iteration of a foreach

I have a function that concatenates a query from POST variables, this I do with a foreach: $id = $_POST['empId']; $query = "UPDATE userInfo SET "; foreach ($_POST as $key => $value) { $query .= "$key = '$value', "; } $query .= " WHERE i...
asked by 15.05.2018 / 21:30
2
answers

@foreach in laravel that goes from 2 objects to 2 objects?

I am building a blog in laravel but I found a problem in my blog template, from the file of routes I send by compact the variable post: Route::get('/blog', function () { $posts = App\Post::latest('published_at')->get(); return view(...
asked by 12.08.2018 / 06:07
5
answers

Scroll List DTO in C #

I have the following code in c #: List<Usuario> ret = new List<Usuario>(); UsuarioRepositorio repositorio = new UsuarioRepositorio(); var dtos = repositorio.Seleccionar(); foreach(dtos) { ret.Add(dtos); } return ret;...
asked by 18.04.2018 / 18:34
1
answer

How can I create an input dictionary with a forEach in Javascript?

What I want to do is create a dictionary in javascript and then use it in python. I have some dynamic inputs that have different attributes that I would like to put in a dictionary how can I do this? I would like an output more or less if:...
asked by 23.08.2018 / 21:54
0
answers

Update value within a Foreach

please help me, I need to update the result of my total every time I change the amount <script type="text/javascript"> function operacion(field) {...
asked by 28.09.2018 / 18:44
0
answers

forEach vs. for in javascript does not come out the same

This is a JavaScript exercise that you can find on the following page: FreeCodeCamp excercise This is my code: function checkCashRegister(price, cash, cid) { debugger; var toReturn = cash - price; var cashArray = [0.01, 0....
asked by 18.08.2018 / 18:12
1
answer

Multi-table mysql query and repeated data

first of all thank you very much in advance for your help, I am learning php and queries based on data and I have some doubts, I am doing a multitasking query that is something like the following: SELECT t.Tourname, c.FechaConcierto, can.nombr...
asked by 31.01.2018 / 06:51
4
answers

How to perform mathematical operations with the values of an array

I have a problem subtracting the values of an array from one another. The sum works perfectly, but the subtraction does not work. It always makes me negative numbers, and that would not be the case. This is my code: var numbers = []; var u...
asked by 17.06.2018 / 13:01
3
answers

Add values of a two-dimensional array and throw your total PHP

There is a method (array_sum) in PHP that adds the values of a two-dimensional array without having to traverse the array, but in this case I need to traverse that array without using this method to display the values per array and its total ....
asked by 13.05.2018 / 06:47
2
answers

Abnormal foreach behavior in php 7.0, repeat the last element in nested foreach

I'm new here, and as the title says the foreach behaves abnormally. I want to list all the driver's schedules per shift (1 = day, 2 = night), in turn these with the days from Monday to Friday (0 = Sunday, 1 = Monday, etc) Bearing in mind that dr...
asked by 11.12.2017 / 22:46