Most voted "foreach" questions
Provides an easy way to iterate over vectors and matrices.
Learn more…324 questions
Sort by count of
-
-1
votes1
answer282
viewsimporting Xml data into Mysql database - Only save the LAST record
In this code all XML records are read, but in the Mysql database only the last XML block is saved. I know that reading each record over-writes the previous one but the strange thing is that I gave…
-
-1
votes1
answer395
viewsI can’t save all records from foreach - LARAVEL
In the user id it has 2 record only that at the time of saving it only saves 1 record and not the 2, as I must do to save correctly ? Follows Code below Controller Lists user data public function…
-
-1
votes1
answer229
views -
-1
votes1
answer88
viewsdisplay the result of a foreach outside the loop
Hello, I need to present the result of a foreach out of the loop. The way I have been doing only presents one result. What I’m doing wrong? //Check bad words $badWords = array('palavra1',…
-
-1
votes1
answer95
viewsHow to pass a default parameter value within a foreach in C#?
Dear friends, How could I pass a default parameter value within a foreach? Example, inside my foreach I have an if that makes a certain comparison with an attribute of my class right?. But by…
-
-1
votes1
answer72
viewsforeach does not run full, only runs 1 time
good afternoon, anyone has any idea why this foreach does not rotate 3 times, and wheel only 1? $pag = 3; {foreach from=$pag item=pg} <div class="fotos-flex active"> {foreach from=$photos…
-
-1
votes1
answer354
views -
-1
votes2
answers847
viewsHow to "bypass" the Maximum Execution time of 30 Seconds exceeded in php?
I have a script that imports the properties of a real estate by an xml. When there are many properties, it gives timeout after 30 seconds (Maximum Execution time of 30 Seconds exceeded). Is there…
-
-1
votes1
answer42
viewsHow to insert a new associated key within PHP Multidimensional Array
The array has the following structure below: $array = [ [['total_arrematado' => 27, 'id' => 5],['total_arrematado' => 10, 'id' => 7]], [['total_arrematado' => 50, 'id' =>…
-
-1
votes1
answer35
viewsLaravel - Controller - Show data from two tables
I’m having trouble showing data for two related tables. Controller: public Function index(){ $tabela = capitulo::orderby('id', 'desc')->paginate(); $tabela1 = documentacao::orderby('id',…
-
-1
votes1
answer49
viewsSkip foreach result every two results
I have some results in the bank and need to align them according to the image below. But I could not. I am doing in Laravel 5.8. <table style="border-collapse: collapse; width: 100%;"…
-
-1
votes1
answer43
viewsHow do I create a counter inside a FORELSE or FOREACH in Laravel?
I am displaying a list of system members. But I would like to display only 10 members using the syntax @forelse in Laravel. How do I implement a counter that displays only the first 10 records in…
-
-1
votes1
answer17
viewsaddeventlistener in querySelectorAll in Reactjs
Fala galera Maybe it’s a simple problem but I’m trying to figure out why it doesn’t work, I researched here in the stack, I found similar questions but they didn’t solve the problem. I have a…
-
-2
votes1
answer483
viewsListing and Counting Rows from a table in Mysql
I am trying to make a list of users who have logged in and at the same time a count of how many times each user has logged in, from log logins in a table, I can not explain very well, so will an…
-
-2
votes1
answer300
viewsForeach group values
I have the following code foreach ($_POST['codmunicipio'] as $key => $valor2) { $codmunicipio = $valor2; $valor_ipl3_f = $_POST['IPL3_valor_F']; $valor_ipl3_j = $_POST['IPL3_valor_J']; $sql3 =…
-
-2
votes2
answers90
viewsForeach returns nothing back
I have a database query that returns an object to me Array ( [0] => stdClass Object ( [id] => 3 [status] => pending [task] => drink juice ) [1] => stdClass Object ( [id] => 17…
-
-2
votes3
answers140
viewsI can’t view all data with foreach in PHP with data from an API
I am trying to bring to a simpler way the following information coming from an API: { "results": [ { "date": "2020-01-05T00:00:00Z", "total": 100, "visits_detail": [ ] }, { "date":…
-
-2
votes2
answers77
viewsCreate new Rows in Bootstrap according to the amount of items in the database with PHP
I need to create a new div class="row" when it reaches the limit of 12 columns, in my case I am using col-md-3. Therefore, the maximum items per column are 4. <?php foreach ($data['palettes'] as…
-
-2
votes2
answers58
viewsTake Data from Session with Foreach
seems simple, but I’m all night researching and testing various methods and I get nothing. So, I decided to post. I have the following item on session: ["prefixo1"]=> array(6) {…
-
-2
votes2
answers61
viewsHow to get the value of buttons created through a foreach loop in php/Laravel?
Personal I have an array with sizes of a product, follow the example of the array: And for each size I create a button through a foreach, follows excerpt from the code where I create the buttons:…
-
-2
votes1
answer25
viewsProblem handling foreach in a PHP array
I’m trying to go through the transaction of the following array but without success: Array ( [date] => 2021-08-07T20:48:14.000-03:00 [transactions] => Array ( [transaction] => Array (…
-
-2
votes1
answer19
viewsHow to Browse a List With Map and Array List Within the Same List (JAVA)Springboot
I need to go through this List (List) however I cannot, I need to pass the value "options",take the value "option_Id", and go through the option_value and bring the option_value_id and Name in…
-
-3
votes1
answer40
viewsChanging strings of an object in a foreach
I’m in trouble: I mount an object from an insert list: This list I put in a variable and insert inside a function with foreach, however, so that it works correctly within the function can not have…
-
-4
votes1
answer328
viewsError "Invalid argument supplied for foreach()" and "Undefined index" in PHP form
I must create 20 inputs that when filled out should show what was typed in them right below, using arrays and foreach, here is the code below: function repeteInput(){ for($i = 1; $i <= 20; $i++){…