Most voted "foreach" questions
Provides an easy way to iterate over vectors and matrices.
Learn more…324 questions
Sort by count of
- 
		0 votes1 answer701 viewsForeach taking only the last recordI’m developing a vendor registration screen, but my foreach is only getting the last record in a total of 3 records. What I might be doing wrong? Below my code and attached to my screen. Thank you… 
- 
		0 votes1 answer95 viewsHow to scroll through an array the right wayGood evening guys, I’m having an immense difficulty regarding arrays... I have the following array: array(6) { [0]=> array(1) { ["cep"]=> array(2) { [0]=> string(8) "15070650" [1]=>… 
- 
		0 votes1 answer98 viewsAccess data within PHP arrayHey, guys, all right? I have a problem with a project I’m working on. I receive a form where the user informs the data but in this form, it is possible that he click a button to insert new inputs… 
- 
		0 votes1 answer48 viewsHow to put a layout for the search results of an input search that is inside echo?I need to put a layout in the search results of input search, I have a page that uses the layout of bootstrap 4 Cards, and I wanted the search results to be the same. This is the script I use in my… 
- 
		0 votes3 answers1090 viewsarray in a php foreachI’ll try to be objective in doubt: I have the following code: <?php foreach ($modelo as $k => $v) { $sql_ = "SELECT * FROM pedido WHERE modelo LIKE '%".$v."%' ORDER BY id ASC"; $disp_sql_ =… 
- 
		0 votes2 answers399 viewsHow to make a @foreach with Relationship Tables in LaravelI’m using Laravel freamwork where in my database I have 2 tables: -> complainants (with the field 'id','complainant','typoacoes_id') -> typos (with id fields, 'name') Both are already with the… 
- 
		0 votes1 answer36 viewsRecover values from an array of the next line in the previous lineI have an array in the format below: Array ( [0] => Array ( [A] => 000001001000003001 [B] => VLR REF COMPENSACAO DE VENDA CONFORME CO1 [C] => 1.1.2.01.020001 [D] => Z4 [E] => [F]… 
- 
		0 votes1 answer56 viewsAdd item in array with PHP foreachI need to pick with the foreach of PHP, the id of the question and the reply of each answered question. I can only get the id of the question, as I would also get the typed answer? Man foreach <?… 
- 
		0 votes1 answer53 viewsForeach jquery concatenate in tableI have a AJAX that in the success brings a response: $(response).each(function(i) { alert(response[i]); $('#tbody').html( "<tr>" + "<td>" + response[i].id + "</td>" + "<td>"… 
- 
		0 votes1 answer92 viewsHow to list all xml for phpGood evening. I have the following xml file: <MusicHistory CompactMode="1"> <Item0 Block="2018-02-11T23:00:00" Folder="Musicas" Music="Zara Larsson - So Good" Composer="" Comment=""… 
- 
		0 votes1 answer245 viewsradio button selected according to BD on foreachGood morning, as I can do to leave the radiobutton selected according to the database, I have a table in the database with the categories being listed in a foreach on the radiobutton, until then… 
- 
		0 votes0 answers22 viewsHow to pick up and display PHP deselected checkbox dataI have a table where a column consists of checkbox. In the future, the status of these checks will be saved in a database for automatic loading, but at the moment, for the purpose of testing and… 
- 
		0 votes1 answer81 viewsFilter Map and ReduceI have the following line of code: $scope.listDeColaboradoresObject.forEach(item => { item.listNmAssunto = $scope.relatorioTotalMensagensRespondidasColab .filter(x => x.nmUsuario ==… 
- 
		0 votes2 answers86 viewsError including Session or foreach in PHP codeI am studying PHP with a book I bought and the exercise is to create a task list. The browser is returning me the following error: Notice: Undefined variable: lista_tarefas in C: Users Elton Desktop… 
- 
		0 votes2 answers67 viewsCheck with php and disable optionI know what you have to do, but I don’t know how to do it. I have the following array: $dados = array 0 => array 'id' => 1 'posicao' => 1 'ativo' => 'sim' 1 => array 'id' => 2… 
- 
		0 votes1 answer92 viewsHow to Recover C# Dynamic Fields for SQLI’m making an ASP site that has dynamic fields in js: a = 0; function GetDynamicTextBox(value) { a++; return '<div class="container bg-light p-3 mb-2"><div class="form-group row… 
- 
		0 votes2 answers195 viewsHow to remove class from other elements by clicking the button?There are several buttons, which when clicking, opens a box with options. How do I so that when I open a box, the others close? var button = document.querySelectorAll(".popup-btn") var pop =… 
- 
		0 votes4 answers712 viewsHow to access only the first position of each row in an array of arrays (matrix / multidimensional array) using foreach?I have a array multidimensional / array of arrays / matrix (as you prefer to call): public string[,] operacoes = { { "SOMA", "", "" }, { "SUBTRAÇÃO", "", "" }, { "MULTIPLICAÇÃO", "", "" }, {… 
- 
		0 votes1 answer916 viewsPassing parameter to Typescript method - Angular 7I’m new to Angular and I need to pass as parameter to the method "load Production" the employee of the time in my HTML ngFor, but I’m not succeeding, the console does not print anything in the… 
- 
		0 votes1 answer129 viewsFunction validate users registrationI’m starting in OO in php, and with the function below I’m trying to check if the name coming from the form is equal to some value coming from my user table before making Insert in the table. I wish… 
- 
		0 votes1 answer686 viewsHow to mount foreach to pick array valuesGood afternoon. How should I ride the foreach to take the values: Barcode; link; Charge. of this array: array ( 'code' => 200, 'data' => array ( 'barcode' => '00000.00000 00000.000000… 
- 
		0 votes1 answer75 viewsFirebase Two foreach duplicating dataFriends, I started developing using Firebase not long ago. I’m "stuck" in a part of development where I’m using a foreach inside another foreach that’s oddly duplicating the results. When I see the… 
- 
		0 votes1 answer71 viewsHow to group array with the same ids in new array?I’m using a php function to get custom Fields data from whmcs sql, but the operation returns the data in an array, separating each id by products. That is, it does not return the product with all… 
- 
		0 votes1 answer79 viewscompare Sql data with two ForeachI’m looking for data from two tables which have an equal column, which is called the prefix column. I tried to mount a foreach inside the other foreach with the data of the two tables and comparing… 
- 
		0 votes1 answer51 viewsHow to use show/Hide inside a PHP foreach?When using the script below it masks only the first line (if I filter or fetch it even changes what is first, but masks only the first from above). Someone can help me? HTML: @foreach($senhas as… 
- 
		0 votes2 answers236 viewsProblem To View Data Json View BladeHello! I’ve tried several times and I’m having difficulty visualizing the data of a Json in a View. I’m passing this data like this in Controller: $validatorES = new EntradaSaidaFormRequest();… 
- 
		0 votes2 answers40 viewsHow to use "for" to work with data in an array whose amount of varied data is unknown?I have the following JSON variable resulting from a php query: $json_string = '[ { "id": 1, "name": "Jogos para PC", "products": [ { "id": 34, "name": "Grand Theft Auto V" }, { "id": 59, "name":… 
- 
		0 votes1 answer207 viewsDisplay variable only once on a foreach and count total rows of an IFI have a script, which basically compares the files of a bank table with the files of a directory, and it shows the files that are NOT in the database and are in the directory. I have 2 problems:… 
- 
		0 votes1 answer38 viewsHow to select in MYSQL, bringing together resultsI need to make a query that returns the amount similar to the below: TIPO 1 unidade 1 unidade 2 unidade n TIPO 2 unidade 1 unidade 2 unidade n The tables are like this: tabela_tipo id|tipo 1 |TIPO 1… 
- 
		0 votes1 answer74 viewsInsert data into the database with foreachI have an array that receives data from a session and I am trying to insert it into the database using foreach but nothing happens. What may be wrong? Follow an example of the array: array(3) {… 
- 
		0 votes2 answers172 viewsForeach in Laravel only returns the first lineI got Following code down on Laravel 7 My controller is taking the many relationship to one as per the model below: public function listarPermissoes() { return $this->hasMany(Acoes::class,… 
- 
		0 votes1 answer59 viewsHow to group items from an array with the same category in PHPI have a array in PHP that follows the following pattern: array(3) { [0]=> array(3) { ["id"]=> string(1) "1" ["categoria"]=> string(7) "Celular" ["produto"]=> string(8) "Motorola" }… 
- 
		0 votes1 answer37 viewsSeparate MYSQL results by specific field for email triggeringI’m making an availability notification system (let me know) but I’m having difficulties in logic to make the iteration on LOOP grouping the results by "email" to trigger separately. CONSULTATION… 
- 
		0 votes1 answer822 viewsHow to resolve error C# "Nullreferenceexception: Object Reference not set to an instance of an Object."?I’m trying to finish a project only that is showing error on the foreach part, and in VSCODE does not report any problem. I’m learning C# now and I can’t figure it out on my own. this is… 
- 
		0 votes2 answers52 viewsProblem with "see more" (button)!I am with a small project that is to optimize the "see more" on a site or application and I came across a problem. <div class="conteudo"> <h2> <span>teste</span> </h2>… 
- 
		0 votes0 answers34 viewsHelp with PHP multidimensional and foreach arrayall right with you guys? I’m studying PHP programming and mainly reading Apis, I came across the.com ticket api for reading movies and sessions, I’m managing to capture the sessions of a certain… 
- 
		0 votes0 answers35 viewsC# - Cascade Repeat Structurefirst good morning! I have a task to feed a "file tree (windows explorer style)" in object format. For this I have initially a method that lists all the files and folders in the directory root of… 
- 
		0 votes1 answer60 viewsHTML table inside another table in a foreach in PHPI wonder if it is possible to Add a Table HTML within another table in a foreach. Explanation why I need this: I have the budgets in the database and each budget can have many composition items. I… 
- 
		0 votes0 answers32 viewsremove part of a php object arrayGood night. I’m trying to foreach an api response. She comes to me like this: { "page": 1, "results": [ { "adult": false, "backdrop_path": "/9WlJFhOSCPnaaSmsrv0B4zA8iUb.jpg", "genre_ids": [ 28, 27,… 
- 
		0 votes0 answers24 viewsClosed cycles in PHPWe create the following function: public function get_ciclo_atual($hoje, $dia_inicial=21, $dia_final=20){ $ciclo = array(); if(date("d", strtotime($hoje)) >= $dia_inicial){ $ciclo[0] = date("Y",… 
- 
		-1 votes2 answers282 viewsforeach PHP for JavascriptI’m in the middle of a project I have to do clustering on a map. I found this algorithm which is in PHP. My doubt is in this foreach: foreach ($markers as $key => $target) { $pixels =… 
- 
		-1 votes1 answer3237 viewsHow to display the values of an Arraylist separately?class Principal { public static void main(String[] args) { Scanner entrada = new Scanner(System.in); ArrayList colecao = new ArrayList(); for (int i = 0; i < 3; i++) { for (int j = 0; j < 2;… 
- 
		-1 votes1 answer1593 viewsForeach repeating the same contentSetting I have a form and via POST send to the page preview.php 10 song names that are divided between 4 arrays. I can generate the 10 Divs containing the position array but when I create the… 
- 
		-1 votes1 answer658 viewsCreate a foreach with a specific condition in PHPI have this condition: if (date('Y-m-d', strtotime($arrayBancas['dataHora'])) == $data->format('Y-m-d')) And I also have an array. For each array entry I need to check the condition and show on… 
- 
		-1 votes1 answer23 viewsLoop(For) doubt with information coming from the databaseE ae personal blz ? I’m having a big problem executing a code of my own. I have a web application made in Windows, which is running locally. In this application I need to generate a report that is… 
- 
		-1 votes2 answers145 viewsWhy use three parameters for this`callback`function?I’m learning Javascript, and I was recreating the type function forEach (wearing a bow tie for) inside prototype of a array. And for that I used a function callback, down below:… 
- 
		-1 votes1 answer61 viewsDecrease a multidimencional arrayGood evening, I am with a dilemma, I have tried in many ways but my knowledge with array is still vague, I would like help in the following, I have two arrays, one of them I already solved with a… 
- 
		-1 votes1 answer49 viewsBring all results out of the foreachI’m not managing to bring all the results out of the foreach. Follow the code: foreach ($_POST['filtroOpt'] as $key=> $value){ $filtro = "AND ".$value." LIKE '%".$_POST['term'][$key]."%' "; echo… 
- 
		-1 votes2 answers44 viewsMysql table return with PHP foreachI have the event table and would like to return all rows of a Mysql query through the foreach in PHP, but it returns only the first line, can help me? Follows the code: <?php… 
- 
		-1 votes1 answer32 viewsHow to generate sequential variables (e.g.: D1, D2, D3) and then merge everything into a single PHP variableI have script using foreach that generates the variables $d, $m, that receive the value of a mysql query and puts this value in the input echo " <input type='text' name='tipo' value='".$d."'>…