php for循环建数据


      $data = [];
      for($i=0; $i<10; $i++) {
        $data[] = $i;
      }
      print_r($data);

执行后打印的结果为:

Array
(
    [0] => 0
    [1] => 1
    [2] => 2
    [3] => 3
    [4] => 4
    [5] => 5
    [6] => 6
    [7] => 7
    [8] => 8
    [9] => 9
)

 

posted @ 2016-12-13 22:59  圆旭  阅读(518)  评论(0编辑  收藏  举报