Most voted "foreach" questions
Provides an easy way to iterate over vectors and matrices.
Learn more…324 questions
Sort by count of
-
1
votes1
answer54
viewsProblem with PHP FOREACH
My problem is that my foreach only works when returning in XML, comes with more than one value in the array, but when it comes only 1, it doesn’t work. The return in XML when comes more than 1 value…
-
1
votes0
answers67
viewsPHP - Split list and print
I’m creating a script for study and I need to split the list into array. So you can be informed in for or foreach. That in each tested account is informed the result on the screen and so on... I’m…
-
1
votes1
answer280
viewsForeach inside foreach is doubling PHP values?
I’m having a problem looping, I am working with 3 tables of the Bank, would be table Anuncio, Opcoes_Anuncio(interconnected) and Opcoes, I’m trying to bring the option data along with the selected…
-
1
votes1
answer161
viewsArray within Array
Good night, I am consuming a webservice and get the data in json with Curl. I have the data stored in the variable $data. What I need is this: Let’s assume that the variable $data has the following…
-
1
votes2
answers289
viewsHow to join different foreach results in an array?
I’m picking up information from movie posters from a movie site, using Simple Html Dom. <?php include("simple_html_dom.php"); $html = file_get_html("http://arcoplex.com.br/?lang=059"); To get the…
-
1
votes1
answer560
viewsMap returning repeated values
I’m making a foreach in a hashmap on the basis of the following arquivo.txt: chaveA;6 chaveA;4 chaveB;3 chaveB;7 chaveC;1 chaveC;1 chaveD;5 For now my code is like this: Scanner scanArquivo = new…
-
1
votes1
answer34
viewsQuestions about data listing!
Hello I am developing a project using the Mysqli extension, and in this taking advantage to use some object-oriented functions! I would like to ask a few questions regarding the data listing, are…
-
1
votes1
answer49
viewsHow to Iterate Checkbox and Foreach in PHP and JS
I have a foreach that shows the data received from the database, I want to display the data only if the checkbox is checked, but the field display works only in the first iteration of Foreach,…
-
1
votes2
answers343
viewsSelect any div from a foreach
Can someone help me? I have this problem when selecting the text inside the div, just select the first foreach text, wanted to select what I click and not only the first <?php foreach($dado as…
-
1
votes1
answer139
viewsPHP/FTP File Verification
Hello, I have the following situation: My company wants to validate all files from a particular folder on FTP with BD (Mysql), to make sure that all files are being used and those that are not…
-
1
votes1
answer129
views -
1
votes1
answer443
viewsHow to separate the results of a SELECT in MYSQL into 2 foreach in PHP?
I have a recipes website where I bring the list of recipes according to the query below: SELECT * FROM receitas WHERE titulo LIKE '%batata%' ORDER BY ordem I wanted to show the first 3 featured…
-
1
votes2
answers144
viewsForeach only works if the array is inside brackets
Something strange is happening, I’m using foreach to add values directly by the ID, only the strange and the function only works if the array is inside a bracket. var elements1 =…
-
1
votes1
answer959
viewsErrorexception : Illegal string offset
I have the following array. $polylines = [ 'latitude' = array(73.9289238, 83.928392832, 03.293892832), 'longitude' = array(-122.29839238, 21.928918291, 30.203929832) ]; I’m trying to execute the…
-
1
votes3
answers385
viewsCalculate values in sub array [PHP]
I have an array with items, and each with a sub-array where we have the values to be added, I’m trying to make each sub-array have its sum returned, and display the following result.. //Esse seria a…
-
1
votes3
answers680
viewsTraversing array of objects
Good night. I have an array of an object and would like to take two values: object(OrgaosJurisdicionais)[17] protected 'data' => array (size=3) 'id' => string '3' (length=1) 'nome' =>…
-
1
votes1
answer88
viewsForeach List does not recognize array
I’m using PHP. I pass the values by _POST, and I have a string, which I turned into an array: By the _POST method it arrives like this: [1v4],,,,[5v3],,,[8v] Remove excess commas, pull the v…
-
1
votes1
answer30
viewsHow to call a function more than once in a lambda Expression?
In Jenkins I’m trying to read a file with groovy and for each line check if it contains any of the information I need. Given the following content of arquivo: amarelo verde vermelho azul The code I…
-
1
votes2
answers93
viewsPHP - doubts with date("Y-m-d")
Good afternoon person, someone could assist me in a doubt. I have this foreach that traverses an array and checks if the CURRENT DATE is equal to $value['Account']['data_expiration'] If it is he…
-
1
votes1
answer44
viewsForeach with querySelectAll() mouseover src [one image at a time]
When I move the mouse I want it to change the background image of only one image instead of all at once <img class=" imagem-do-produto"…
-
1
votes1
answer39
viewsList of objects generating string
I have an object list Person that contains a list of Endereços. I would like to print this person with the addresses on string. var pessoa = new Pessoa() { Nome = "Jão" }; var e = new Endereco() {…
-
1
votes1
answer141
viewsList table array horizontally and vertically
I’m trying to list the company name horizontally, the quantities of the products just below each company name, and the product name in the first column vertically. My code is this, but not this…
-
1
votes1
answer65
viewsFução to find and remove term in the array does not work with variavél!
implementing in my project the user solution Augusto Vasques in the matter : How to remove an array from occurrence found within a sub array! I came across the situation of not being able to search…
-
1
votes2
answers46
viewsHow to iterate over a string by obtaining the indices of each character in C++?
Example done in Python: editor = 'Luiz' for contador, letra in enumerate(editor): print(f"A letra '{letra}' está no índice {contador} ") I was wondering if it’s possible to do this kind of counter…
-
0
votes2
answers2047
viewsTraverse components of form C#
Hello I have a table coming from the database, with several rows and columns. One of these columns is stored the address of the previously saved image. Now I need to go through all Picturebox and…
-
0
votes1
answer144
viewsJquery - For loop inside a DIV
You guys, good morning. Simple: I’m giving a For a div: <div class="Laço"> <div class="ItemLaco"></div> <div class="ItemLaco"></div> <div…
-
0
votes0
answers27
views -
0
votes1
answer370
viewsDisplaying vector with foreach - PHP
Someone would have an example of a foreach to display the vector data below? Code: Array ( [empregadoTO] => Array ( [0] => EmpregadoTO Object ( [id:EmpregadoTO:private] => 1…
-
0
votes1
answer161
viewsC# foreach aborted
When I try to move the controls of a FlowLayouPanel to another flpPropriedades -> flpReserva through a loop foreach he leaves in the middle and does not complete the transition. foreach (Control…
-
0
votes2
answers231
viewsMultidimensional array in C# equal PHP?
First time here on this forum, I usually use stack overflow but come on. My question refers to the array in C#: I’m more familiar with PHP and in php we can name our array indexes for example:…
-
0
votes1
answer84
viewsProblem with foreach Shopping Cart
I’m having a problem with foreach and I wonder if there’s another method to not have to change all the code. What happens is that each time more than one product is added to the cart, if we buy for…
-
0
votes1
answer1324
views -
0
votes1
answer27
viewsCheck selected category
I need to check if the categories chosen by the user exist in the categories suggested by the php system I was able to save in the array the categories chosen by the user and also categories…
-
0
votes0
answers57
viewsHow foreach actually works in PHP
Could someone explain how really works the foreach and how to use? I’ve researched and can not understand, I’ve seen it right here in stackoveflow, has THAT ONE topic, but it is not explained, I…
-
0
votes2
answers252
viewsReturn 2 values in a foreach
I would like to return two values in one foreach, can help me? For Each item In Funcao() teste1 = gostaria de pegar aqui o resultado 1 teste2 = gostaria de pegar aqui o resultado 2 Next Private…
-
0
votes0
answers64
views -
0
votes2
answers91
views -
0
votes1
answer916
viewsHow to go through an object and filter this object?
I’m trying to go through an object and after that, filter the same. I’m using this code, but it’s not working. Someone could help me and if possible explain the code ? const objeto = { idade: 20,…
-
0
votes0
answers363
viewsAbout foreach array while loop for...to leave results in alphabetical order
<? $n = 0; $limite = 10; while ($n <= $limite-1){ $dates = array($user["members"][$n]["rank"]); foreach ($dates as $value){ echo $value; } $n++; } ?> it returns the following value: 87 41…
-
0
votes1
answer231
viewsHow to get first value returned by foreach
Personal I am new in programming and I am trying to solve my problem with foreach... I have a foreach that returns me the groups of photos that have photos in them... however I need to take the…
-
0
votes1
answer66
viewsForeach in fields
Good afternoon. I’m having trouble showing the data of a form, where they can have multiple addresses and within those addresses can have several involved. I tried something like:…
-
0
votes0
answers611
viewsRetrieve FOR loop variable inside a FOREACH - php
Hi, I have two loops in the structure of my code. The first is a FOR that mounts an array with data. And I have a foreach that runs through a BD data. I want to use the variable that returns in FOR…
-
0
votes3
answers49
viewsSend information from a Viwer Data grid to sql database
I’m putting together an order form using c#. The problem is that when I try to send the products that are listed in the Data Grid Viewer to the database, the program reads only the line where the…
-
0
votes1
answer59
viewsI want to use 2 threads inside the foreach C#
I don’t have much experience in C#. But I’m trying to understand the code of a program I have here. Here use the following code: foreach(var item in _main.entrada) { .... } I want to include…
-
0
votes1
answer155
viewsHow to print on screen or console, a string array in php
I’ve been going through the documentation, but it’s unclear how I do it. I have an array of strings: $remetente = $con->real_escape_string($_REQUEST['rem']); $arrai= array(); $remetenteArray[] =…
-
0
votes2
answers38
viewsHelp Foreach stdClass
Good morning :D I need a light! I need to take all 'ids' of users of a table and pass to another table, but when I give a foreach it returns me only 1 result as stdClass. Follows the code: $stmt =…
-
0
votes1
answer288
viewsUse foreach in a table checkbox
In the code that I am creating there is a view of all the users of the site in an html table, until then everything right, however when selecting multiple checkbox to delete several users of the…
-
0
votes1
answer533
viewsHow to use Foreach in a multidimensional array in PHP
I would like to know how to run the entire array only with Foreach: $Marcas = array(array('Fiat', 'Volkswagen', 'Audi'),array('Yamaha', 'Suzuki', 'Honda'),array('Samsung', 'Motorola', 'Apple'));…
-
0
votes2
answers279
viewsHow to remove null value from a foreach or array
I am making a query in a table that has a blank value(student:note). On one page I do the function with select and play the array on a Return to call on another page, but I can’t delete the blank…
-
0
votes1
answer34
viewsProblem iterating an array in php
I have the following code. $array = array(1,2,3); $arr1 = array(3, 4, 5); $data = []; for($i = 0; $i < count($array); $i++){ $data["ca"] = $array[$i]; for($k = 0; $k < count($arr1); $k++){…