dongshang6790
2014-05-19 16:29
浏览 178
已采纳

在php中一次取10个数组元素?

       echo "<table title='mxit:table:full' style='width: 100%' width='100%'><colgroup span='2' width='50%'></colgroup>";




        foreach($arr['chart_data'] as $key => $element){



          echo "<tr>";


            foreach($element as $subkey => $subelement){

              // $subelement =chop($subelement,'DIRECTSegment');

                 if($subkey++ < 2) {
                if($key == 0)
                {

               echo "<td align='center;' style='color:white;'>$subelement</td>";
                }

                else if($subkey == 1)
                {
                    echo "<td align='center;' style='color:white;'>$subelement</td>";   
                }

                else
                {

                echo "<td align='center;' style='color:white;'><a href='getdata.php?key=$key'>".$subelement."</a></td>";
                }
                 }

            }

              }
           echo "</tr>";

       echo "</table>";

How do i take only 10 elements of my array $arr['chart_data'] at a time ?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题