foreach

Objective-C NSMutableArray - foreach loop with objects of multiple classes

Hi, I have the NSMutableArray *children in the datastructure-class "Foo" which is the superclass of many others, like "Bar1" and "Bar2". That array stores Bar1 and Bar2 objects to get a tree-like recursive parent-children-structure of subclasses from Foo. To access the objects in the array, I loop through them using the foreach loop in ...

Grabbing Just The Top Entry From A LINQ Query

I basically have a lot of poorly designed code to do something that, I'm sure, can be done far more elegantly. What I'm trying to do is grab the last date from a database table. var Result = from a in DB.Table orderby a.Date descending select new {Date = a}; foreach(var Row in Result) { LastDate = Row.Date.Date; break; } Basicall...

Creating foreach loops using Code Igniter controller and view

Hello, This is a situation I have found myself in a few times and I just want clear it up once and for all. Best just to show you what I need to do in some example code. My Controller function my_controller() { $id = $this->uri->segment(3); $this->db->from('cue_sheets'); $this->db->where('id', $id); $data['get_cue_sheets'] = $this-...

need to store values from foreach loop into array

Need to store values from foreach loop into an array, need help doing that. Code below does not work, only stores the last value, tried $items .= ..., but that is not doing the trick either, any help will be appreciated. <?php foreach($group_membership as $i => $username) { $items = array($username); } print_r($items); ?> ...

VB.NET :For each loops with Resultset from LINQ 2 SQL

The below code will fill User Records in "users". Dim users= From p In oDbUser.USERs Where p.STATE= "MI" And p.STATUS = 1 Can anyone tell me how can i use a foreaach loop in the result and take each indidual row items ? ...

How to make a object (class) foreachable in D?

Hi, how can I make a class usable in a foreach statement? The class contains a associative array (e.g. string[string]). So the foreach statement use this array as source. So this is what I want: auto obj = new Obj(); foreach (key, value; obj) { ... } Do I need to implement a interface someting like that? EDIT: The solution: p...

Perl, foreach order

Does Perl's foreach loop operator require that the list items be presented in order? For example my @a=(1,2,3); foreach my $item (@a) { print $item; } will always print 1 2 3? I suspect so, but I can't find it documented. ...

How Array of our custom classes work with foreach without implemented IEnumerable ?

Hello everybody This long title already contain all my question so i just want to give example MyClass[] array How this array work with Foreach without implement IEnumerable interface's method ? ...

Is there a more elegant way to act on the first and last items in a foreach enumeration than count++?

Is there a more elegant way to act on the first and last items when iterating through a foreach loop than incrementing a separate counter and checking it each time? For instance, the following code outputs: >>> [line1], [line2], [line3], [line4] <<< which requires knowing when you are acting on the first and last item. Is there a mo...

PHP foreach help

Hello I have an array that looks like this, Array ( [cfi_title] => Mr [cfi_firstname] => Firstname [cfi_surname] => Lastname [cfi_email] => [email protected] [cfi_subscribe_promotional] => [cfi_tnc] => [friendsName] => Array ( [0] => Firstname 1 [1] => Firstname 2 ...

How to Create an Array from a Single Variable and Form Multiple Foreach Loops?

I'm fairly proficient in HTML/CSS, but very new when it comes to the likes of PHP and Javascript. I've jumped headfirst into coding Wordpress shortcodes (basically php functions), and so far, through trial and error and seemingly endless browser refreshes, I've been able to figure everything out. I just hit a huge wall though, hence wh...

Can't build full html table in QTextEdit with std::for_each...

Hi. Here is my code function: void ReportHistory::update(void) { ui.output->clear(); ui.output->setCurrentFont(QFont("Arial", 8, QFont::Normal)); QString title = "My Title"; QStringList headers = QString("Header1,Header2,Header3,Header4,Header5,Header6").split(","); QString html = QString( "<html>" \ "<head>" \ "<meta Cont...

JQUERY - how Two elements - IMG - DIV when hover over IMG show/hide the DIV - added with hover hide/show on img allready

Im very new to the wonder that is jquery. and i just figure out how to make my img buttons show/hide with a opacity difference (as such) <script type="text/javascript"> <![CDATA[ $(".ExcommKnap").mouseover(function () { $(this).stop().fadeTo('fast', 0.5, function(){}) }); $(".ExcommKnap").mouseout(function () { $(this).stop().fad...

Converting 'foreach' to 'for' loop or vice versa with ReSharper possible?

Hi, Is it possible to mark a foreach loop code block and convert it to a for loop with ReSharper? Or with Visual Studio? Thanks! ...

Nested foreach loop in perl only looping once.

I've written a perl script that opens two files which contain lists. I want to find items in the first list that are not in the second list. The script uses two foreach loops. The outer loop goes through each line of the first list, extracting the necessary item information. The inner loop goes through the second list, extracting the ite...

Foreach file in directory jQuery

How can I do a foreach(File file in Directory) kind of thing in jQuery. Thank you! ...

Does the foreach loop in C# guarantee an order of evaluation?

Logically, one would think that the foreach loop in C# would evaluate in the same order as an incrementing for loop. Experimentally, it does. However, there appears to be no such confirmation on the MSDN site. Is it simply such an apparent answer that they did not think to include that information on the site? Or is there the possibili...

adding an element to multidimensional array when within foreach loop (PHP)

Hi I'm trying to check if a certain category is allready selected by looping through an array of categories also I want to add another element to the array whci is just a bit to indicate is the category selcated my categories array looks like this 0=>array(category_id=>12,category_name=>"blogger") 1=>array(category_id=>13,category_na...

Efficient foreach child evaluation in parallel

I have a list of objects, each with a bool ShouldRun() method on them. I am currently iterating over the list of objects, and checking ShouldRun() on each object, and calling Run() on the first one to return true foreach (child in Children) { if (child.ShouldRun()) { child.Run(); break; } } I would like to do t...

foreach Loop in LaTeX

Scenario: I have a main Latex file (main.tex) in which I include a subfile (appendix.tex) using the subfiles package. Role of appendix.tex: It further includes all the appendices as subfiles kept in an appendix subfolder, so that I just need to include the appendix.tex in the main.tex file. Current Situation: I have to manually list th...