+ 21
use of do while loop with a real life example
4 Respuestas
+ 24
do while loop is used when u what that the loop executes at least 1 time and then checks the conditions and executes itself till the condition becomes false
like a new restaurant is open in your area now u want to know is the food of that restaurant is accord to ur taste or not so u can visit there frequently
but for that u had to go in restaurant at least one time and if ur conditions satisfied then u will visit the restaurant frequently
just like that do while loop works
+ 5
php
$to_pee = true;
do{
$to_pee=false
}while($to_pee)
+ 2
Using Facebook as an example. Click to view your friends list. Everybody has a variable number of friends, so you need code to iterate over each friend to display their photo, name, and profile link.
foreach(var $friend in $user->friends) {
show_friend($friend);
}
+ 1
$displaywarning=true
do{
echo "warning"
echo "do you want to see this warning again?"
}while($displaywarning=false)
[when you uncheck it to not seeing it more]