Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP中中断当前循环迭代并继续循环_Php_While Loop - Fatal编程技术网

在PHP中中断当前循环迭代并继续循环

在PHP中中断当前循环迭代并继续循环,php,while-loop,Php,While Loop,从数据库检索数据 while($row_posts = mysql_fetch_array($run_posts)) { $post_id1=$row_posts['userID']; $post_title=$row_posts['torrent_hash']; try{ $transmission = new Transmission\Transmission(); $torrent = $transmission->get($post_tit

从数据库检索数据

while($row_posts = mysql_fetch_array($run_posts))
    {
    $post_id1=$row_posts['userID'];
    $post_title=$row_posts['torrent_hash'];
try{
    $transmission = new Transmission\Transmission();
    $torrent = $transmission->get($post_title);
    $torrent->getName();
    }
    catch (Exception $e) {
          echo 'Caught exception: ',  $e->getMessage(), "\n";
       }
使用传输软件检查哈希值

while($row_posts = mysql_fetch_array($run_posts))
    {
    $post_id1=$row_posts['userID'];
    $post_title=$row_posts['torrent_hash'];
try{
    $transmission = new Transmission\Transmission();
    $torrent = $transmission->get($post_title);
    $torrent->getName();
    }
    catch (Exception $e) {
          echo 'Caught exception: ',  $e->getMessage(), "\n";
       }
如果在传输中未找到散列id,则显示如下错误

Caught exception: Torrent with ID 58bd21a7938cb1d65f737bcb6031111816d924d9 not found 
Notice: Undefined variable: torrent in C:\xampp\htdocs\final\info.php on line 46

Fatal error: Call to a member function isFinished() on a non-object in C:\xampp\htdocs\final\info.php on line 46

我需要输出,比如如果发生运行时异常,那么只需中断第一个循环并从数据库执行第二个值即可?

Try command
continue

continue在循环结构中用于跳过当前循环迭代的其余部分,并在条件评估时继续执行,然后开始下一个迭代