$data = array( ['subject'=>'低段語文','one_name'=>'寫作卷','two_name'=>'古詩詞第1首','title'= >'11111'], ['subject'=>'低段語文','one_name'=>'寫作卷','two_name'=>'古詩詞第1首','title'=> ;'22222'], ['subject'=>'低段語文','one_name'=>'測試卷','two_name'=>'古詩詞第2首','title'=> '666666'], ['subject'=>'低段數學','one_name'=>'練習卷','two_name'=>'低段數學1','title'=>'3333333 '], ['subject'=>'低段數學','one_name'=>'練習卷','two_name'=>'低段數學2','title'=>'444444'] , ['subject'=>'低段數學','one_name'=>'評估卷','two_name'=>'低段數學1','title'=>'7777777'], [ 'subject'=>'高段語文','one_name'=>'繪畫卷','two_name'=>'繪畫1','title'=>'555555'], );
想先按subject封裝然後底下是one_name 在是two_name 弄成一層層封裝的那樣。
致自己2021-08-31 10:28:43
$newArr = [];foreach ($data as $v){ foreach ($v as $kk=>$vv){ $newArr[$kk][]=$vvv; }}}
# }}on; ##這種?