2014. szeptember 11., csütörtök

continue: folytatás a következő ciklustól

pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 5.11 Using the continue Statement</title>
</head>
<body>
<div>
<?php
$counter = -4;
for ( ;  $counter <= 10; $counter++ ) {
    if ( $counter == 0 ) {
        continue;
    }
    $temp = 4000/$counter;
    print "4000 divided by $counter is... $temp<br />";
}
?>
</div>
</body>
</html>
Eredmény:

4000 divided by -4 is... -1000
4000 divided by -3 is... -1333.3333333333
4000 divided by -2 is... -2000
4000 divided by -1 is... -4000
4000 divided by 1 is... 4000
4000 divided by 2 is... 2000
4000 divided by 3 is... 1333.3333333333
4000 divided by 4 is... 1000
4000 divided by 5 is... 800
4000 divided by 6 is... 666.66666666667
4000 divided by 7 is... 571.42857142857
4000 divided by 8 is... 500
4000 divided by 9 is... 444.44444444444
4000 divided by 10 is... 400

Nincsenek megjegyzések:

Megjegyzés küldése