I'm working with arrays of image filepaths. A typical array might have 5 image filepaths stored in it.
For each array, I want to pull out just the "best" photo to display as a thumbnail for the collection.
I find looping and arrays very confusing and after 4 hours of trying to figure out how to structure this, I'm at a loss.
Here are...
Hello everyone,
How do I find out which function or target is modifying the items in a foreach loop in a multithreaded application?
I continously keep getting the error "Collection was modified; enumeration operation may not execute". I'm not removing or adding any items to the generic list within the for loop.
I want to find out how it...
Is it possible to loop through a data() object?
Suppose this is my code:
$('#mydiv').data('bar','lorem');
$('#mydiv').data('foo','ipsum');
$('#mydiv').data('cam','dolores');
How do I loop through this? Can each() be used for this?
...
Some time ago I asked a question about nested loops on SO and as it was, there were queries inside the loops of my example and I got a clear answer:
NEVER EVER NEVER put an SQL query inside a loop
I've tried ever since and mostly it works. Just need to make an effort and write a query that retrieves all you need at once.
BUT what ...
I would like to loop through audio in VB.NET.
Here is my code:
While blnAlert = True
My.Computer.Audio.Play("C:\cat_1.wav")
End While
But it freezes the app.
Cheers.
...
I want to do something like this:
foreach ($array as $key=>$value except when $key="id")
{
// whatever
}
... without having to put an "if" clause inside the body of the loop. It is not guaranteed that "id" will the be the first or last element in the array, and I don't really want to unset or slice the array, because that will be expe...
Ok I have a table with a few fields. One of the fields is username. There are many times where the username is the same, for example:
username: bob
password: bob
report: 1
username: bob
password: bob
report: 2
I did a SQL statement to select * where username='bob'; but when I do the following PHP function, it will only retur...
I have two queries, as following:
SELECT SQL_CALC_FOUND_ROWS Id, Name FROM my_table WHERE Name LIKE '%prashant%' LIMIT 0, 10;
SELECT FOUND_ROWS();
I want to execute both these queries in a single attempt.
$result = mysql_query($query);
But then tell me how I will handle each tables set separately. Actually in ASP.NET we uses datas...
I am trying a "very" simple task to output values of each rows from a dataset :
$Data = ''
for($i=0;$i -le $ds.Tables[1].Rows.Count;$i++)
{
write-host 'value is : '+$i+' '+$ds.Tables[1].Rows[$i][0]
}
OUTPUT :
value is : +0+ +System.Data.DataSet.Tables[1].Rows[0][0]
value is : +1+ +System.Data.DataSet.Tables[1].Rows[1][0]
value i...
I have a thread that appends rows to self.output and a loop that runs until self.done is True (or the max execution time is reached).
Is there a more efficient way to do this other than using a while loop that constantly checks to see if it's done. The while loop causes the CPU to spike to 100% while it's running..
time.clock()
while ...
I have a table of housing listings. I would like to keep a maximum of 10 listings per city.
(Most cities have less than 10 listings).
When I do this query:
select city, count(city) as cityCount from tREaltyTrac group by city
SQL returns:
Acampo 1
Acton 1
Adelanto 20
Agua Dulce 1
Aguanga 1
Akron 19
Albany 12
Albion 3
Al...
I have a dataset with 4 rows. I am using 2 foreach loops to get my data out. The outer foreach needs to loop once and I need the inner loop to loop 4x. Is there a way to do this or do I need to split the array?
foreach($reports as $key=>$val)
{
if($val['rpt_type'] == 'Sooa')
{
foreach($val as $foo)
{
...
Is is possible to do this;
for i in range(some_number):
#do something
without the i? If you just want to do something x amount of times and don't need the iterator.
...
Hey!
Please let me know if this is bad practice or in someway a bad thing to do. The thing is in my program I need to make a method which goes through the root element and all child nodes of that element. My elements are like this:
|--ID--|--Parent--|--Additinal info--|
| 1 | 0 | root element |
| 2 | 0 | root ele...
I see a lot of 'related' questions showing up, but none I looked at answer this specific scenario.
During a while/for loop that parses a result set generated from a SQL select statement, what is the best way to prevent the next line from being outputted if the line before it contains the same field data (whether it be the 1st field or t...
I'm writing a script that logs errors from another program and restarts the program where it left off when it encounters an error. For whatever reasons, the developers of this program didn't feel it necessary to put this functionality into their program by default.
Anyways, the program takes an input file, parses it, and creates an outp...
Hi,
Is there a statment like Exit For, except instead of exiting the loop it just moves to the next item.
For example:
For Each I As Item In Items
If I = x Then
'Move to next item
End If
' Do something
Next
I know could simply add an Else to the If statment so it would read as follows:
For Each I As Item In Items
If I = x T...
Hi, I'm new to this, so sorry if my question has been asked before. I have searched but have not been able to find, or perhaps recognise, an answer. I am using visual studio 2008 and creating an app in vb.net.
I have 4 arrays named:- account1 account2 account3 account4. They all have 4 elements.
I want to assign values to the elements i...
Penz says that the problem could be solved by Multios and coproc features in the thread.
However, I am unsure about the solution.
I do know that you can use multios as
ls -1 > file | less
but I have never used such that you have two inputs.
How can you use these features to have a pipe loop in Zsh?
...
I have an array:
$arr_nav = array( array( "id" => "apple",
"url" => "apple.html",
"name" => "My Apple"
),
array( "id" => "orange",
"url" => "orange/oranges.html",
"name" => "View All Oranges",
),
array( "id" => "pear",
"url" => "pear.html",
"name" => "A Pear"
)
);...