cari

Rumah  >  Soal Jawab  >  teks badan

Transformasi dan pemasangan tatasusunan PHP

array(2) {
  [0]=>
  array(15) {
    ["t_id"]=>
    string(2) "87"
    ["b_id"]=>
    string(2) "21"
    ["year"]=>
    string(4) "2018"
    ["01"]=>
    string(6) ",09,16"
    ["02"]=>
    NULL
    ["03"]=>
    NULL
    ["04"]=>
    NULL
    ["05"]=>
    NULL
    ["06"]=>
    NULL
    ["07"]=>
    NULL
    ["08"]=>
    NULL
    ["09"]=>
    NULL
    [10]=>
    NULL
    [11]=>
    NULL
    [12]=>
    NULL
  }
  [1]=>
  array(15) {
    ["t_id"]=>
    string(2) "86"
    ["b_id"]=>
    string(2) "21"
    ["year"]=>
    string(4) "2017"
    ["01"]=>
    NULL
    ["02"]=>
    NULL
    ["03"]=>
    NULL
    ["04"]=>
    string(0) ""
    ["05"]=>
    string(15) ",23,23,24,24,23"
    ["06"]=>
    string(9) ",20,12,15"
    ["07"]=>
    string(6) ",19,10"
    ["08"]=>
    string(0) ""
    ["09"]=>
    string(0) ""
    [10]=>
    string(6) ",18,18"
    [11]=>
    string(3) ",09"
    [12]=>
    NULL
  }
}

Tatasusunan di atas dibaca dari pangkalan data
Tahun di atas ialah tahun, 01 hingga 12 adalah Januari hingga Disember, dan kemudian, 16, 17, 25 adalah tarikhnya

Cara membuatnya dalam format di bawah! Tuhan tolong saya

array(
      '2017' => array(
      '04'=>array('15','20'),
      '05'=>array('05','18'),
      '11'=>array('11','19'),
     ),
    '2018' => array(
      '03'=>array('15','20'),
      '06'=>array('05','18'),
      '11'=>array('11','19'),
     ),

2017 mewakili tahun, 04 mewakili bulan, 15, 20 mewakili tarikh 15 dan 20

曾经蜡笔没有小新曾经蜡笔没有小新2751 hari yang lalu714

membalas semua(1)saya akan balas

  • 伊谢尔伦

    伊谢尔伦2017-05-16 13:18:39

    $a = tatasusunan(

            array(
                'year'=>'2017',
                'one'=>',16,17,25,27,18,27',
                'two'=>'',
                'three'=>',16,17,25,27,18,19,15,24'
            ),
            array(
                'year'=>'2018',
                'one'=>'',
                'two'=>',16,17,25,27,18,27',
                'three'=>',16,17,25,27,18,19,15,24'
                ),
            );
    
        foreach($a as $key => $value){
            $year = $value['year'];
            unset($value['year']);
            foreach($value as $k => $v){
                $result = explode(',',substr($v,1));
                $time[$year][$k] = $result;
            }
        }
        
        var_dump($time);
        
        最上面还有一行 $a = array(  显示不了··

    balas
    0
  • Batalbalas