foreach

How can I use nested Async (WCF) calls within foreach loops in Silverlight ?

The following code contains a few nested async calls within some foreach loops. I know the silverlight/wcf calls are called asyncrously -but how can I ensure that my wcfPhotographers, wcfCategories and wcfCategories objects are ready before the foreach loop start? I'm sure I am going about this all the wrong way -and would appreciate an...

How to use foreach() in any controller function of Codeigniter

Hey Guys, I’ve stucked with a problem. Can any body help me for….. “How to use foreach() in any controller function of Codeigniter”. Actually, i’ve a piece of codes which are placed in a Controller function in whihc i’m using foreach(). Here is the piece of code….. $this->load->model('board/dboard_members_model'); $data['query4'] = $thi...

How do I create a loop based off this array?

I'm trying to process this array, first testing for the presence of a check, then extrapolating the data from quantity to return a valid price. Here's the input for fixed amounts of items, with no variable quantity. <input type="checkbox" name="measure[<?=$item->id?>][checked]" value="<?=$item->id?>"> <input type="hidden" name="measure...

LINQ VB.NET variable not found when looping through grouped query

I'm trying to do the following LINQ grouping, which works in the debugger (the results are populated in the GroupedOrders object. But VS 2008 gives me the following error at design time... Name 'x' is not declared Dim GroupedOrders = (From m In thisConsultant.orders _ Group m By Key = m.commCode Int...

foreach: how to iterate this

object(stdClass)[1] public 'inbox' => array 0 => object(stdClass)[2] public 'from' => string '55512351' (length=8) public 'date' => string '29/03/2010' (length=10) public 'time' => string '21:24:10' (length=8) public 'utcOffsetSeconds' => int 3600 public 're...

Generic foreach loop in C#.

The compiler, given the following code, tells me "Use of unassigned local variable 'x'." Any thoughts? public delegate Y Function<X,Y>(X x); public class Map<X,Y> { private Function<X,Y> F; public Map(Function f) { F = f; } public Collection<Y> Over(Collection<X> xs){ List<Y> ys = new List<Y>(); ...

How to automatically assign different Z-Index Values to multiple elements with jQuery

for example i have the markup <div> <img src="#" alt=""/> <img src="#" alt=""/> <img src="#" alt=""/> <div> I want to select $('div img') and then assign each one a z-index value so the first one is 3, second 2, third 1. Is this simple with jQuery? Thanks ...

PHP: Splitting an array into a deeper array

Hello, I have the following array: Array( [0] => 0,0 [1] => 0,1 [2] => 0,2 [3] => 0,3 [4] => 1,0 [5] => 1,1 [6] => 1,2 [7] => 2,0 [8] => 2,1 [9] => 2,2 [10] => 2,3 ) And I would like to split it into the following structure: Array( [0] => Array ( [0] => 0 [1] => 1 [2] => 2 ...

Initializing an array in Java using the 'advanced' for each loop

Is it possible to initialise an array in Java using the 'advanced' for loop? e.g. Integer[ ] numbers = new Integer[20]; int counter = 0; for ( Integer i : numbers ) { i = counter++; } for ( Integer i : numbers ) { System.out.println(i); } This prints all nulls, why is that? ...

HOw do you combine two foreach loops into one.

The language is PHP. I have one foreach ( $a as $b) and another foreach ($c as $d => $e). How do i combine them to read as one. I tired foreach (($a as $b) && ($c as $d => $e)), but that is rubbish. ...

Matching array elements to get an array element at another index

I have a PHP array that I'm using to generate an HTML form. The PHP array is this: <?php $vdb = array ( array( "Alabama", 275), array( "Alaska", 197), array( "Arizona", 3322)); ?> The PHP to generate the HTML form is below. I need to have the value be the name of the s...

Problem with anonymouse delegate within foreach

public Form1() { InitializeComponent(); Collection<Test> tests = new Collection<Test>(); tests.Add(new Test("test1")); tests.Add(new Test("test2")); foreach (Test test in tests) { Button button = new Button(); button.Text = test.name; button.Click...

std::for_each on a member function with 1 argument

I'm wondering how to implement what is stated in the title. I've tried something like... std::for_each( a.begin(), a.end(), std::mem_fun_ref( &myClass::someFunc ) ) but I get an error saying that the "term" (I"m assuming it means the 3rd argument) doesn't evaluate to a function with 1 argument, even though someFunc does take one argume...

Iterate over rows/checkboxes in a RadGrid

Hi, I have a Telerik RadGrid with a GridTemplateColumn that contains a checkbox, as follows: <telerik:GridTemplateColumn HeaderText="MINE" UniqueName="MyTemplateColumn"> <ItemTemplate> <asp:CheckBox id="MyCheckBox" runat="server"></asp:CheckBox> </ItemTemplate> </telerik:GridTemplateColumn> I want to set the box t...

for_each but for setting each element to a value in C++

I have the following code to assign a value to all the elements of a vector: x = 100; for (int i=0;i<vect.size();i++) { vect[i] = x; } It's straightforward enough, but I'm wondering if there is a function in the STL that does the same thing; something like for_each, but for assignment. ...

Concatenating a Text in front of Individual Database Records with Tcl

Hello: In short, currently I am using the following code to pull records from multiple tables in a Sqlite Db and insert them in a single combobox ($SearchBar): set SrchVals1 [db eval {SELECT DISTINCT Stitle From Subcontract Order By Stitle ASC}] set SrchVals2 [db eval {... set SrchVals3 ... set SrchValsALL [concat $SrchVals1 $SrchVals...

Why can't I add an event to each element in a collection that refers to Itself rather than the last element in the "for(){}" statement

On Window's load, every DD element inside Quote_App should have an onCLick event appended that triggers the function Lorem, however, Lorem returns the nodeName and Id of the last element in the For statement rather than that of the element that trigged the function. I would want Lorem to return the nodeName and Id of the element that tri...

Why can't I toggle the visibility of every element (within a group) in a for statement, only the last element in the group gets toggled?

The script fires Toggle fine on each Control's (Controls[i]) Click. If the Control's first OL element is not Visible it should be set Visible and all other elements in Controls that are not the current Control (Controls[i]) should be set Hidden. If the Control's first OL element is Visible it should be set Hidden. .js function Toggle(C...

jQuery toggle on a PHP foreach statement

The code for the page is the following <?php foreach ($organization->index() as $id=>$content) { ?> <a href="#" id="obtain_branch"><?= $content->name?></a> <div id="directory_brnach"><?= $content->about?></div> <?php } ?> The JavaScript code using jQuery is // Directory inner branches $('#obtain_branch').click(function(){ $('#dir...

need help passing multiple variables from foreach loop to test in switch case statement

$list_of_groups = array("FACULTY","STAFF"); foreach ($list_of_groups as $i => $group) { $user_in_group = $adldap->user_ingroup($username,$group); print "<h2>Group: ".$group." user in group? ".$user_in_group."</h2>"; // if 1, means yes } Need to print run the appropriate function based on what returns true. There are user's that...