Questions tagged [foreach]

0

votes
1

answer
15

Views

How to fix “Warning: Invalid argument supplied for foreach()”

I'm making a website in Laravel, CSS, and HTML. The current issue is that my code, won't gather information from files inside the folder '_videos' with this 'summon' code. @foreach ($videos as $video) {{$page->title}} @endforeach Error message Warning: Invalid argument supplied for foreach() Folder:...
Audun Hilden
1

votes
2

answer
35

Views

How to handle API error in a foreach loop R?

FYI, based on some comments I added more information. I created the following function that is making a call to an API: keyword_checker
Franck
1

votes
1

answer
93

Views

Querying Distant Relationships

I have three tables: users, accounts and hotels. Users and Accounts are connected with belongstoMany relation and Accounts and Hotels are connected the same way. Each User has Accounts and those Accounts have Hotels. When I have Auth::user(), how I can return all hotels? $accounts = Auth::user()->ac...
Aleks Per
1

votes
2

answer
44

Views

Angular - Check if all Subscriber in a list are finished

I use an interval to post a variable amount of data in a forEach loop to a backend. What I want to do is: If the first call of the post method is not finished but the interval already wants to call the method a second time, the call should be blocked until the first call it finished. I try to show t...
WeSt
1

votes
1

answer
22

Views

Reading corresponding lines from 2 text files with 2 foreach() loops

Needing to pull 2 objects from 2 different txt files, 1 getting the user id and the other the rule id. The line numbers should correlate to each other from both text files. The issue is the 2 foreach() loop, the outer one runs once and the inner one run for each rule id in the txt, problem is I dont...
mjzach22
1

votes
3

answer
23

Views

Nested Json php for loop status[0] issue

Hi I have a Json format like below: { 'result':0, 'status':[ { 'id':'00001', 'vid':'yes' }, { 'id':'00002', 'vid':'yes' }, { 'id':'00003', 'vid':'no' } ] } I want to use the json_decode function in PHP to decode the id values such as below: 00001 00002 00003 here is the code I am using: $url = file_...
MALKAVIAN
1

votes
1

answer
114

Views

Is ArrayList.forEach() a mutative operation?

I have a HashMap groups which maps to ArrayList objects for its values. I wanted to re-assign the values given they meet a particular condition (i.e. in this case, they are present in another list) and came across the forEach method. Here's how I implemented it. I could not find any documentation as...
Garikai
1

votes
2

answer
64

Views

Iterating LinkedList using streams is altering result list due to RaceCondtion

We are iterating the LinkedList using Streams in java8, and creating another list. But due the race condition the result List size got alatered. List InfoList = new LinkedList(); documentList.stream() .parallel() .forEach(document -> { Info descriptiveInfo = objectFactory.createDescriptiveInfo(); Li...
Raghavan
1

votes
5

answer
61

Views

Show multiples of a given number within a range

How can I fix the following code in better way (alternative way to iterate range from first element to last element? My goal is to write kotlin code in most efficient and simplest way I am looking someone tell me instead of n/7 what should I write to get the same result of code val numList = 1..20...
Jack
1

votes
3

answer
51

Views

if a value is on mysqli database do not create a button on php

I have a database table like ----------------- | id | time | |----|----------| | 1 | 9am-10am | | 2 | 11am-12pm| and a PHP array $times= array('8am-9am','9am-10am','10am-11am','11am-12pm','12pm-1pm','1pm-2pm','2pm-3pm','3pm-4pm','4pm-5pm','5pm-6pm','6pm-7pm','7pm-8pm','8pm-9pm','9pm-10pm'); My...
Mondin A.
1

votes
5

answer
54

Views

JavaScript: Is it possible to update the value of an array item with forEach?

I want to cycle through an array of numbers and if any of those numbers are single digit add a 0 before it, eg 1 becomes 01. I could do this with a for loop but was wondering if I could use forEach as it seems neater. Would anyone know if this can be done? My code so far: numArr.forEach(function(ite...
MeltingDog
1

votes
2

answer
51

Views

Angular resolve company name from company ID in a loop

I am new to angular and rxjs, i want to resolve company name from a company id in an array. I have company data in this format: |---------------------|------------------| | CompanyID | CompanyName | |---------------------|------------------| | 1234 | CompanyA |...
hades
1

votes
3

answer
60

Views

How do I write Foreach to get as same result as my query?

I have a code like that: List BankDepositHistoryDTOs = new List(); for (int i = 0; i < query.Count; i++) { BankDepositHistoryDTO b = new BankDepositHistoryDTO(); b.AccountId = query[i].AccountId; b.Id = query[i].Id; b.Amount = query[i].Amount; b.AdditionalData = query[i].AdditionalData; b.ClientIp =...
Ali Eshghi
1

votes
3

answer
6.3k

Views

PHP Session Array list

How can I print a list of session arrays with php? I have this php code: foreach($wall as $v) { $_SESSION['nickname'] = $v['user']['nickname']; $_SESSION['imageURL'] = $v['user']['imageURL']; $_SESSION['clubURL'] = $v['user']['clubURL']; $_SESSION['id'] = $v['id']; $_SESSION['date'] = $v['date']; $...
Carlos Martins
1

votes
0

answer
76

Views

R parallel rocessing with for loop in function

I am building a parallel processing loop which has a for loop nestled inside. for simplicity sake I am only including one line of code within the function and for loop but in reality there are about 1000 lines of code. In this small example, I am building a grid for which I would like to iterate ov...
CooperBuck
1

votes
1

answer
49

Views

C# Assistance in foreach datagridview data removal

Scenario: I am loading a DataGridView with data from a database, so in order to do so I'm using a foreach-loop, now the problem here is that when going on the DataGridView for the second time it loads the data from before and the data being looped in now. In order to fix that I did this: private vo...
user7943
1

votes
1

answer
122

Views

How to iterate for each loop for duplicate values

What I expect to happen: The program should find the expected Web Element from the list, click on it, find the contract id and match with the given contract id. If yes, break the loop else click back button and proceed until the conditions are satisfied. Actual issue : On running this for each loop;...
srini lavanya
1

votes
2

answer
64

Views

how to fix the displayed table in php

I have a code that read from text files and allow the user to make a search then the system display the result in a table that contains the file name and the line number. what I need is to delete the columns that are empty. I will appreciate any help. screenshot: Where is the error in the table? Cod...
Ghgh Lhlh
1

votes
1

answer
208

Views

doParallel:::doParallelSNOW complains when foreach(…, .export) is specified

I'm curious what the design argument for doParallel:::doParallelSNOW() giving a warning when globals are explicitly specified in .export could be? For example, library('doParallel') registerDoParallel(cl
HenrikB
1

votes
0

answer
54

Views
1

votes
1

answer
294

Views

delayed foreach loop

I have a script that is moving .pak files from server1 to server2 with a foreach loop. I need the foreach loop to wait in-between the file moves to copy over. I'm looking to add a 30 second delay in the loop. $server1 = 'C:\Users\Administrator\AppData\Local\Temp' ## current source folder $server2 =...
Roshan Lidl
1

votes
1

answer
57

Views

use multiple for loops in a td element in laravel

Hello guys i have 3 eloquent tables members, pledge and campaign and they are have a relationship amongst each other namely: for member model protected $table = 'members'; public function loans() { return $this->hasMany(Loan::class, 'borrower_id', 'id'); } public function user() { return $this->hasO...
DoubleAsam
1

votes
1

answer
36

Views

nodejs foreach not returning correct value

I'm trying to use this function to get some total counts from my log files in s3, and then add them to a total varaible to return. But i can't get the callback correct. I've tried the callback in the end of the foreach loop, and also in the ' else' at the end, but in either case totalRowCount is al...
Ron
1

votes
1

answer
179

Views

ensure forEach loop finishes before next command js

Apologies if I'm just being thick. I've tried the search function, but being relatively new to all of this, I'm struggling to work out the solution. I think I'm probably not searching for the right keyword. I have a route in my Node.js application that has two forEach loops in it. I want forEach loo...
KevinD
1

votes
2

answer
46

Views

Finding the difference between the dates in months based on particular ID and solving in R

Below is my sample data set which has many unique ID's and I have to find out the difference between the first occurrence and the second occurrence in the First_Diff column and the difference between the second occurrence and the third in Second_Diff column and so on. They are many occurrences in th...
Zhoe
1

votes
1

answer
55

Views

foreach until find some value

I have a code that get categories from database but I don't know how to get all subcategories(parents). This my php code : function get_the_category($allCats,$filter_id = null) { $re_struct_cat = array(); $filter_id = 10; $ids = array(); $xx = array(); foreach($allCats as $cat_key=>$cat_val) { $re...
oxmix pro
1

votes
1

answer
114

Views

Make R foreach and doMC %dopar% work with single-threaded data.table fwrite?

I've had issues with %dopar% (with a doMC backend) and fwrite() intermittently on my Debian 9 PC and a Red Hat 4.8.5 high performance computing cluster. The behavior isn't always consistent, but, in short, fwrite and foreach malfunction--even when specifically requesting that fwrite only use one cor...
Zach O
1

votes
2

answer
1k

Views

ORA-01795: maximum number of expressions in a list is 1000 error with myibatis

I am writing an update query with IN clause in which I am passing List update table set postcode={#postcode} where id in #{item} This runs fine when I have less than 1000 records in addresses.If there are more than 1000 records I get below error: ORA-01795: maximum number of expressions in a list i...
user9193174
1

votes
1

answer
238

Views

laravel 5.1 foreach Trying to get property of non-object

i am having 3-4 for each in my code which all use Eloquent and in all of them i get the same error Trying to get property of non-object when i dd the first argument of foreach which is an eloquent it returns an array of json with all the data in database of that table so its not returning null th...
Farshad
1

votes
2

answer
59

Views

Access the value from array of objects

code props.thumbnails.forEach(value=>{ console.log(value.photo.thumbnail_url); }) error TypeError: Cannot read property 'thumbnail_url' of undefined When I try props.thumbnails.forEach(value=>{ console.log(value.photo); }) response {owner: 7, thumbnail_url: 'images/CACHE/images/barack_obama-2/888e0...
ilovecse
1

votes
2

answer
40

Views

Looping through foreach and creating Arrays

I am trying to loop through and Array of unique zones in a property data base and then create an array for the size, value and building sizes for each of those zones. My problem is that I can create the array, but since each foreach that is loop through has the array with the same name, so the array...
Michiel Wackers
1

votes
1

answer
81

Views

For Multiple Azure Table Storage Accounts Achieve, how to achieve over 20,000+ requests per second for insert and query?

I am wondering how to achieve over 20,0000 requests per second on Azure storage accounts. I understand that data needs to be separated into multiple storage accounts in order to surpass those limits however I am unable to achieve this with current code. I have achieved around 20,000 requests per sec...
Manbrew
1

votes
1

answer
85

Views

Custom input number in a foreach loop

I have make a new style for my input number, and this work well. My problem is when I add this is a foreach structure this doesn't work. I think the problem is the ID change the value, but inside the foreach all all inputs have the same ID. This is my code inside the foreach: -
Marco Romano
1

votes
1

answer
52

Views

Populate dynamic HTML table from MySQL tables

At the moment I got incomplete what I need, how can I continue to display the SELECT results in their respective tables? As you can see in the example above - there is a image at the end of topic - the first dynamically generated table was populated with your right data. You can see by the title of...
Bender
1

votes
1

answer
43

Views

Foreach loop for multiple photos laravel

Im trying to display all photos associated with an ad. I can access one of them like so But when I try to get them all by looping like this @foreach ($Advert->photo as $photo) @endforeach I get the folloiwng error Invalid argument supplied for foreach()
Andre
1

votes
1

answer
53

Views

Is it possible to process a for loop in parallel within the same stored procedure?

Have a SQL Server stored procedure where I want to loop through a set of options that I read from a table. So say a table has 100 options. My stored procedure will loop through these options and for each option I need to do some checks - by querying few specific tables based on the option and flag...
Rahul J
1

votes
0

answer
45

Views

Adding a space/tab to make a differences between parent comment and child comment in PHP Laravel?

I am using Laravel 5.2 and I have a page which contain a 'comment' from the users and it can be replied by another user. My case is same like in this stackoverflow case. I am following its correct answer. But mine is still not quite working. The child comments doesn't have a space/tab, so the diffe...
hendraspt
1

votes
0

answer
65

Views

Multi-threaded code crashes on server but not on VS

I have a multi-threaded c# code that connects to a MySql server. List itemLst=new List(); //fills the list here ParallelOptions po=new ParallelOptions(); po.MaxDegreeOfParallelism = 45; Parallel.ForEach(itemLst,po,item=> { //Open connection to MySql server //do some SELECT queries //do 1 insert and...
ORIK
1

votes
1

answer
79

Views

How Change Array Key Values in Foreach Loop?

I filter the values ​​in the array and create a new array. But the keys in the output are the same. I used the array in a new foreach loop to fix it but gave the same output again. Array ([0] => text1',number,'text2 [1] => text3',number,'text4 [2] => text5',number,'text6) the above example is a...
Mrs. DkaYs
1

votes
1

answer
64

Views

How to write a for_each loop with IDE-managed Components in c++builder [closed]

I am new to c++ (c++builder) and was wondering, how i could write for each loops, which loop for example through all the TTabItem's in my TTabControll. __published: // IDE-managed Components TTabControl *TabControl1; TTabItem *TTabItem1; TTabItem *TTabItem2; Now i want to do something like: for (...
Chris B

View additional questions