$data = array( ['subject'=>'Low Section Chinese','one_name'=>'Writing Volume','two_name'=>'Old Poetry No. 1','title'= >'11111'], ['subject'=>'Low Section Chinese','one_name'=>'Writing Volume','two_name'=>'Old Poetry No. 1','title'=> ;'22222'], ['subject'=>'Low section Chinese','one_name'=>'Test paper','two_name'=>'Old Poetry No. 2','title'=> '666666'], ['subject'=>'Low Section Mathematics','one_name'=>'Exercise Paper','two_name'=>'Low Section Mathematics 1','title'=>'333333 '], ['subject'=>'Low Section Mathematics','one_name'=>'Exercise Paper','two_name'=>'Low Section Mathematics 2','title'=>'444444'] , ['subject'=>'Low Section Mathematics','one_name'=>'Evaluation Paper','two_name'=>'Low Section Mathematics 1','title'=>'777777'], [ 'subject'=>'High-level Chinese','one_name'=>'Painting Volume','two_name'=>'Painting 1','title'=>'555555'], );
I want to encapsulate it by subject first, then one_name at the bottom and two_name to make it encapsulated layer by layer.
致自己2021-08-31 10:28:43
$newArr = [];foreach ($data as $v){ foreach ($v as $kk=>$vv){ $newArr[$kk][]=$vv; }}
This kind?
猪老湿2021-08-31 09:42:00
I’ll sort out the code and send it again. There’s no format and it seems too laborious