I have the following code below, my question is, I want to break out of the while loop if the user enters "n" and also continue with the next foreach interation. Please see my comment within.
foreach($nodeid as $nid){
$query= $dbh->query("SELECT * FROM Nodes WHERE Node_ID = '$nid' AND New = 1")or die(mysql_error());
if($query->rowCount() > 0)
{
while (1) {
fputs(STDOUT, "
"."***New Node*** : $nid
Do you want to add ? [y,n]: ");
$response = strtolower(trim(fgets(STDIN)));
if( $response == 'y' ) {
#do something then break and go to next foreach.
} elseif( $response == 'n' ) {
#go to next foreach $nid
} else {
echo "
", "I don't understand your option, let's try this again", "
";
continue;
}
}
}
}