loops

How can I loop this (JSON)

{ "fulltime": [ {"name": "oscar godson", "age": "20", "email": "[email protected]"}, {"name": "daniel erickson", "age": "25", "email": "[email protected]"}, {"name": "john doe", "age": "18", "email": "[email protected]"} ], "parttime":[ {"name": "bill johnson", "age": "35"...

Are the limits of for loops calculated once or with each loop?

Is the limit in the following loop (12332*324234) calculated once or every time the loop runs? for(int i=0; i<12332*324234;i++) { //Do something! } ...

Batch converting videos in folders and sub folders

I have a huge collection of videos that all need to be converted into mp4. The folder structure is like this Events Chicago Boston San Fran London Expo Inside each event holds all of videos in either avi format or .mkv. I want them to be converted to the same file name. but with the mp4 extension. My question is how do I loop...

how to find that is there any loop exist in the link list using two pointers?

Possible Duplicate: How to determine if a linked list has a cycle using only two memory locations. hello i have been asked in an interview that how can i find a loop exists in a link list using only two pointers. i have done the following: 1) find the center of the link list each time 2) by iterating this at the end both th...

Showing Wordpress posts on two pages

Hi all, I have three pages on my site. Let's call them home, page2, and page3. My 'home' page is set as a static front page. My 'page2' is set up as the blog page. What I want is the following: I want page2 to display blog posts with a certain category (of which ID is known). AND I want page3 to display blog posts with a certain c...

Advanced MySQl query to fetch date specific records within the same table

Hi, I need to findout a better and quick way to query MySQL table to get specific data for each day in a given date range, where the table has two date columns specifying start and end date. Table example: Promotions columns: ID startDate EndDate Discount CategoryID ======================================================...

VB2010 - For Loop Exiting Issue

I have a simple for loop with the following code For i As Integer = 0 To 4 Snake(i).X = (120 - 20 * i) Snake(i).Y = 120 SnakeBody(i).Location = New Point(Snake(i).X, Snake(i).Y) Snake(i).Facing = 3 Next i But for some reason I unable to debug it. I place a breakpoint on the line...

Batch translating with Google Language API

I am trying to utilize Google's AJAX Language API to translate each value in an array. for(var n=0; n < mytext.length; n++) { google.language.translate(mytext[n], originalLanguage, newLanguage, function(result){ if(!result.error){ document.getElementById("caption") += mytext[n]+" has been translated to "+result.translation; } ...

how to calculate total no of iteration of innermost loop of nested for loop? is there any formula?

for example int count=0 for(int i=0;i<12;i++) for(int j=i+1;j<10;j++) for(int k=j+1;k<8;k++) count++; System.out.println("count = "+count); or for(int i=0;i<I;i++) for(int j=i+1;j<J;j++) for(int k=j+1;k<K;k++) : : : for(int z=y+1;z,<Z;z,++,) count++; w...

Foreach loop with multiple arrays

This is what I want: foreach($_POST['something'] as $something){ foreach($_POST['example'] as $example){ $query = mysql_query("INSERT INTO table (row, row2) VALUES ('{$something}','{$example}')"); } } $_POST['something'] and $_POST['example'] are arrays from an input with name="something[]" and name="example[]". T...

Writing a Quicksort with one loop

My brother wants me to optimize my code by only having one loop. I don't see how a Quicksort can only have one loop and work. (He told me to remove the inner loop) public class QuickSort { public static void Quick(int[] target, int lo, int hi) { if (lo >= hi) { return; } Random numberGenerator = new Random(); ...

overwrite php loop while looping it, then break?

Hi there, I was wondering if this code snippet is considered legal: $arr = array(123,456,789,123,456,789); foreach($arr as $a) { $arr = $a; break; } //prints 123 echo $arr; It executes, but are there any pitfalls i should know using this method? Update: Here is the actual problem You have an array as follows from the databas...

PHP Coding Efficiency: How to fill an array without using [variableName++] (probably easy)

Something about using $array_increment++ to fill an array seem inefficient, even though it works. Is there a more efficient way to fill $color_names in the code below than using a variable to walk through the array? Since I'm using a foreach and 'if' to fill the array, it's harder to figure out a different way than using ++. $array_inc...

Removing things from Python list during for loop

Here is my code: toBe =[] #Check if there is any get request if request.GET.items() != []: for x in DB: try: #This is removing the PMT that is spcific to the name if request.GET['pmtName'] != "None": if not request.GET['pmtName'] in x['tags']: print x['title'], x['...

R - How to turn a loop to a function in R

Thank you for your reading. I often find that I need to apply a function to slices of my data, and then bind the outputs. I usually build a loop for that purpose, but I am sure I am doing it wrong, and that in R I should be using a different way of thinking. Can you please help me learn a better way to do this? With thanks, adam r...

multiple inputs with similar names

So I have a few inputs with the name session and they increment.... session0 session1 session2. If I want to run them through a loop how would I do that. I'm using jquery. for example.. for(i=0,i<10,i++) { var num = (session + i).value + i; } So what I want is the loop to go through all the inputs with prefix session and output their...

Need help with VB.NET List Logic

Hey guys, so I am creating a List(Of String), always of size 9. This list contains True/False values. I need to go through this list and find the 3 values that are True (will never be more than 3, but could be less) and then set 3 string values in my code to the 3 index's of those values + 1. Here is my current code: Private Sub SetDe...

IDL - define array name within a loop

I may be going about this the wrong way, but I'm trying define and fill arrays within a loop. for i = 0,39 do begin xx = long(findgen(n+1l)*sx + line1x[i]) sz = size(xx) arrayname = 'line' + strtrim(i,2) arrayname = findgen(3,sz[1]) arrayname[0,*] = xx arrayname[1,*] = yy arrayname[2,*] = vertline endfor This obviously won't work, ...

append number to variable name and call it in a loop (php) (smarty)

Hi. I have a simple question. I need to append 1,2,3 etc to a variable name in smarty. The variables are $user1, $user2, $user3 etc. I use smarty to do a simple loop like this: {section name=user_info start=1 loop=$users} <tr> <td> User{$smarty.section.user_info.index} </td> // prints user1, user2, user3 etc ...

checking if a xml node exists in ASP Classic

Hi, For a project I'm doing I have a varied number of nodes with node names of nib"number"_title So I'm using a for loop and within that loop I'm using getElementsByTagName to ge the node but It brings up an error if it's trying to find a node thats not there. Microsoft VBScript runtime (0x800A01A8) Object required: 'xml.getElementsByT...