for迴圈輸出的語句,其中有的值要變動怎麼處理

來源:互聯網
上載者:User
for迴圈輸出的語句,其中有的值要變動怎麼辦
本帖最後由 rightnow9 於 2013-01-22 16:36:37 編輯






  • 上面的調用資料庫輸出的內容,第四個
  • 需要加class="last" 用下面的php代碼應該怎麼修改,才能讓他在第四個的時候 加上 class="last"
    ??$arr=explode("|",$_MODULE[linknamea]);
    ??$arrlink=explode("|",$_MODULE[linka]);
    ??for($t = 0; $t ????????
    ??????echo '
  • '.$arr[$t].'
  • ';
    ??????}??
    ?>


    ------解決方案--------------------
      $arr=explode("
    ------解決方案--------------------
    ",$_MODULE[linknamea]);
    $arrlink=explode("
    ------解決方案--------------------
    ",$_MODULE[linka]);
    for($t = 0; $t if($t == 3 ){
    echo '
  • '.$arr[$t].'
  • ';continue;
    }
    echo '
  • '.$arr[$t].'
  • ';
    }
    ?>


    加個if判斷
    ------解決方案--------------------

    $arr=explode("
    ------解決方案--------------------
    ",$_MODULE[linknamea]);
    $arrlink = explode("
    ------解決方案--------------------
    ",$_MODULE[linka]);
    $count = count($arr);
    for($t = 0; $t <$count $t++){
    if( $t==3 )
    echo '
  • '.$arr[$t].'
  • ';
    else
    } echo '
  • '.$arr[$t].'
  • ';
    ?>



    試下上面代碼符合你需求不
    ------解決方案--------------------

    $arr=explode("
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.