note 33964 added to control-structures.for

From: Date: Sat, 12 Jul 2003 07:39:37 +0000
Subject: note 33964 added to control-structures.for
Groups: php.notes 
Request: Send a blank email to php-notes+get-51953@lists.php.net to get a copy of this message
for ($n=5;$n<=100;$n++){ for ($m=2;$m<=$n-1;$m++){ if ($n%$m==0){ $primo=false; break; }else{ $primo=true; } } if ($primo==false){ print "EL NUMERO: ".$n." NO ES PRIMO<br>"; }else{ print "EL NUMERO: ".$n." ES PRIMO<br>"; } } el bucle ademas de romperlo con break tambien podemos romperlo haciendo que la variable contadora incumpla la condicion for ($i=1;$i<=10;$i++){ print $i."<br>"; if ($i==5) $i=11; } ---- Manual Page -- http://www.php.net/manual/en/control-structures.for.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33964 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33964&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33964&report=yes

« previous php.notes (#51953) next »