PHP头条
热点:

php循环,该怎么解决


php循环
























  • 上边的形式该怎么循环,新手求救。。。。
    ------解决方案--------------------
    $arr = array(
        'images/small_case_1.jpg',
        'images/small_case_2.jpg',
        'images/small_case_3.jpg',
        'images/small_case_4.jpg',
        'images/small_case_5.jpg',
        'images/small_case_6.jpg',
        'images/small_case_7.jpg',
        'images/small_case_8.jpg',
        'images/small_case_9.jpg'
    );

    function arr2li($arr){
        $html  = '';
        if(is_array($arr) && !empty($arr)){
            $count = count($arr);
            for($i=0; $i<$count; $i++){
                $rem = $i%3;
                $html .= ($i!=0 && $rem==0) ? "\n\r\n\r" : "";
                $html .= ($rem==0) ? "
  • \n\r
      \n\r" : "";
                  $html .= sprintf("
    • \n\r", $arr[$i]);
                  $html .= ($i+1==$count) ? "
    \n\r
  • " : "";
            }
        }
        return $html;
    }

    /*










































  • */

    echo arr2li($arr);

    ------解决方案--------------------
    $result=mysql_query("select * from case_list"); 
    while($row=mysql_fetch_assoc($result)){
           $ar[]=$row;
    }
    foreach(array_chunk($ar,3) as $v){
        echo "
  • \n
      \n";
      foreach($v as $vl) echo "
    • \n";
      echo "
    \n
  • \n";
    }

    www.phpzy.comtrue/phprm/4377.htmlTechArticlephp循环,该怎么解决 php循环 上边的形式该怎么循环,新手求救。。。。 ------解决方案-------------------- $arr=array( 'images/small_case_1.jpg', 'images/small_case_2.jpg', 'images/small_case_3.jpg', 'images/small_...

    相关文章

    相关频道:

    PHP之友评论

    今天推荐