简体   繁体   中英

Alternative to “goto” in PHP

my php server use PHP Version 5.2.17 and php goto dont work.

how to do this loop without "goto"??

while ($i <= $dadosrolados) {
    a:
    $j = rand(1,10);
    if (isset($um) and $j == 1) {
        goto a;
    }
    else {
        $dados["Dado ".$i] = "$j";
    }
    $i++;
}
do {
  $j = rand(1,10);
} while (isset($um) and $j == 1);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM