When I was in school we learned to program in java.
the loop formats where very simple to me.
for( initialization; termination; increment)
the format in which the for loop is in makes it very easy for me to understand when the loop begins and where it ends.
however I am having a very difficult time understanding the loops in php.
in chapter 2 page 63 there is a for-each loop. it was easy enough for me to understand. the loop was used with an array so I understood that when the array ended so did the loop. the problem for me though was understanding how to do a for-each loop without an array. if I lets say wanted to print 10 times on the screen “hello” - how would I go about doing it with a for-each loop? (I don't think that using a while loop is very efficient)
also. in chapter 3 page 93. there is a while loop in the code that prints the query of movies with their movie types. I don't understand the increment of this loop. how does PHP know to move to the next row if there is no statement telling it to like in the example in chapter 2 page 70 (the one that prints the number of movies the user selected) where there was a statement
$numlist = $numlist + 1;
telling the loop to move to the next on the list.
I not sure if I explained my difficulty easily enough to understand
- but I’m sure that whoever learned java will know what I mean.
please help me.
thanks in advance