Combine foreach output data

I´m working on a project where depending on the situation, I need to combine some output data into a single variable. *$array contains different user information $array[]= array( 'ts3_uuid' => $value['client_unique_identifier'], 'ch...
more »

2017-09-09 14:09 (2) Answers

PHP echo all subfolder images

I have a directory with subfolders containing images. I need to display all these on one page, and also their folder name, so something like this: echo Subfolder name echo image, image, image echo Subfolder2 name echo image2, image2 , image2 etc...
more »

2017-09-07 18:09 (1) Answers

split foreach loop based on some column value

I have a table with a column name type,how can i show results based on its column values in one query ? Tags id|name|type //type can be fixed,price Tag::orderBy('id', 'desc')->get(); Now i want to show price and fixed in two different parti...
more »

2017-08-26 01:08 (2) Answers

Combining json output from multiple foreach loop

I have php script which returns video streams as output. Output contains multiple unique streams. I am trying to encode output into json but because of multiple foreach loop its not giving proper output Code : <?php if (isset($_GET["id"])) ...
more »

2017-08-20 19:08 (2) Answers

Alternative to using ref in foreach?

I have a modifying method with a signature like private bool Modify(ref MyClass obj); that will make modifications to obj and indicate succes with it's return value. Modify is not reassigning the reference (I know that this wouldn't work), just mo...
more »

2017-07-28 20:07 (2) Answers

List<T>.AddRange and the yield statement

I am aware that the yield keyword indicates that the method in which it appears is an iterator. I was just wondering how that works with something like List<T>.AddRange. Let's use the below example: static void Main() { foreach (int i in...
more »

2017-07-26 04:07 (3) Answers

Nested Foreach loop runs too many times - C#

I have 2 foreach loops, 1 nested inside the other. There are 115 total items in 2 collections. What I'm wanting to do is have the first item from the first collection written to the console and then the first item from the second collection written t...
more »

2017-07-24 14:07 (2) Answers

Parallel.ForEach with tuple return c#

Based on this example I'm trying to make a parallel foreach with tuple return. double min = double.MaxValue; object syncObject = new object(); Parallel.ForEach(collection, () => double.MaxValue, (item, loopState, localState) => { ...
more »

2017-07-22 21:07 (2) Answers

javascript foreach find and update

Let say I have an array of tree type data [ { 'id': 1, 'name': 'root', 'parent_id': 1 }, { 'id': 2, 'name': 'level 1', 'parent_id': 1 }, { 'id': 3, 'name': 'level 2', 'parent_id': 1 }, { 'id': 4, 'name': 'level 2.1', 'parent_id': 3 } ] is it...
more »

2017-07-05 18:07 (3) Answers

Powershell convert string to array

How do I change: $Text = "Apple Pear Peach Banana" to $Text = @("Apple", "Pear", "Peach", "Banana") I am planning to feed the array to a foreach loop. The input the user is prompted to enter fruit with a space between (I will use Read-Host for ...
more »

2017-06-06 19:06 (4) Answers

Reset arrays value inside angular.foreach loop

I have an empty array of objects like this: var a = [ {}, {}, {}, {}, {}, {} ]; And an array of properties: var colors = ["red", "green", "blue"]; I need to assign each color in "colors" to every element of "a" array with angular foreach. But t...
more »

2017-05-08 08:05 (3) Answers

C# Foreach keep adding the same item to list

I am having issues with my simple foreach. I am trying to get data from the database to my list. IList<DeliveredTaskModel> deliveredTaskModel = new List<DeliveredTaskModel>(); // lines of code if (materialUsed.Count > 0) { fore...
more »

2017-04-24 10:04 (4) Answers