$ Array = array (){
[0] => array (6 ){
["Id"] => string (1) "2"
["Lessonid"] => string (3) "200"
["Userid"] => string (4) "6038"
["Username"] => string (8) "jsc11101"
["Lessontitle"] => string (47) "Module1-Unit2 I'm From China"
["Courseid"] => string (1) "4"
}
[1] => array (6 ){
["Id"] => string (1) "3"
["Lessonid"] => string (3) "201"
["Userid"] => string (4) "6038"
["Username"] => string (8) "jsc11101"
["Lessontitle"] => string (33) "Module2-Unit1 I Can Speak English"
["Courseid"] => string (1) "4"
}
[5] => array (6)
........................
}
Number of times of learning with the same lessonid
$ Study_num = array ();
Foreach ($ array as $ value ){
$ Study_num [$ value ['lesonid'] = (empty ($ study_num [$ value ['lesonid'])? 0: $ study_num1 [$ value ['lesonid']) + 1;
// If $ study_num [$ value ['lesonid'] is null for the first calendar
}
Number of times: $ study_num [$ lessionid]
Convert to an array with lessonid as the key
$ Lessonid_array = array ();
Foreach ($ array as $ key => $ value ){
$ Lessonid_array [$ value [lessonid] = $ value;
}
Learning text name: $ lessonid_array [$ lessonid] ['lesontitle']
Merge Arrays
Foreach ($ study_num as $ key => $ value ){
$ Lessonid_array [$ key] [count] = $ value;
}
The output array format is as follows:
$ A_array = array (){
Lessonid => array (7 ){
["Id"] => string (1) "3"
["Lessonid"] => string (3) "Learning text ID"
["Userid"] => string (4) "6038"
["Username"] => string (8) "jsc11101"
["Lessontitle"] => string (33) "Learning text name"
["Courseid"] => string (1) "4"
["Count"] => "learning times"
}
}
From the column xiaxia0083