If you feel the urge to leave a nested loop with goto, better think again. Probably you've got a piece of your code that should be refactored into a function.
Instead of
<?php
for ($i=0; $i<10; $i++) {
for ($j=$i, $j<11; $j++) {
if ( $data[$i] === $data[$j] )
goto foundit;
}
}
echo "Sorry, no match";
goto nextAction;
foundit:
echo "Duplicate at $i and $j)";
nextAction:
?>
you better write
<?php
list($success, $i, $j) = searchForDuplicate( $data );
if ($success)
echo "Found it at ($i, $j)";
else
echo "Sorry, no match";
function searchForDuplicate( &$data )
{
for ($i=0; $i<10; $i++) {
for ($j=$i, $j<11; $j++) {
if ( $data[$i] === $data[$j] )
return [ true, $i, $j ];
}
}
return [false];
}
?>
or return [$i, $j] and [-1, -1] if you don't like an extra $success variable. Refactoring into a function is cleaner and gives you an auto-documentation about what the loop is doing.