我是PHP新手。我想要做的是在foreach循環中隱藏相同的數據。如何使用PHP在foreach循環中對相同的下一個值進行排序?
這裏是我的代碼:
foreach($recording_record as $row){
echo $row->criteria_title;
echo $row->question_title;
}
我目前的界面:
我多麼希望我的接口爲:
這是我的print_r數據:
Array ([0] => stdClass Object ([record_id] => 6 [qm_id] => 2 [qm_title] => QM LEAD 2 [record_filename] => abcdefgh.mp3 [userid] => 1002 [unique_id] => 1325554791.71044 [supervisor_id] => 1000 [date_created] => 2013-05-14 05:29:24 [status] => 3 [id] => 6 [callid] => 1325554791.71044 [callerid] => 0383153394 [queuename] => t1-BM_OE [extension] => SIP/1003 [ivrtime] => 2013-05-14 11:14:36 [queuetime] => 2012-01-03 09:40:33 [connecttime] => 2013-05-09 09:40:36 [disconnecttime] => 2012-01-03 09:46:34 [callduration] => 358 [holdduration] => 0 [queueduration] => 3 [ansduration] => 3 [ringduration] => 0 [lastevent] => COMPLETEAGENT [transfer] => [wrapups] => ,12 [tenantid] => 1 [supervisor] => 1005 [username] => Fara [userpass] => 1234 [lastname] => Binti Johari [firstname] => Nurul Farahhin [userlevel] => 2 [usercreated] => 2011-03-26 23:11:56 [lastlogin] => 2012-10-13 20:17:10 [userexten] => [sessionid] => [userstatusid] => 0 [apptype] => webagent [statustimestamp] => 2012-10-13 20:33:21 [lastuserstatusid] => 1 [pqueuetimeout] => 0 [queueroutetype] => 1 [queueroutevalue] => 4 [userdbstatus] => A [criteria_id] => 1 [criteria_title] => Did not demonstrate inappropriate behavior - Zero Tolerance Policy [criteria_rate] => 40 [question_id] => 4 [question_title] => Question 2 [question_type] => n [question_score_y_yes] => [question_score_y_no] => [question_score_y_answer] => [question_score_y] => [question_score_n_a] => 1 [question_score_n_a_value] => True [question_score_n_b] => 0 [question_score_n_b_value] => False [question_score_n_c] => 0 [question_score_n_c_value] => [question_score_n_d] => 0 [question_score_n_d_value] => [question_score_n_e] => 0 [question_score_n_e_value] => [question_score_n_answer] => [question_score_n] =>) [1] => stdClass Object ([record_id] => 6 [qm_id] => 2 [qm_title] => QM LEAD 2 [record_filename] => abcdefgh.mp3 [userid] => 1002 [unique_id] => 1325554791.71044 [supervisor_id] => 1000 [date_created] => 2013-05-14 05:29:24 [status] => 3 [id] => 6 [callid] => 1325554791.71044 [callerid] => 0383153394 [queuename] => t1-BM_OE [extension] => SIP/1003 [ivrtime] => 2013-05-14 11:14:36 [queuetime] => 2012-01-03 09:40:33 [connecttime] => 2013-05-09 09:40:36 [disconnecttime] => 2012-01-03 09:46:34 [callduration] => 358 [holdduration] => 0 [queueduration] => 3 [ansduration] => 3 [ringduration] => 0 [lastevent] => COMPLETEAGENT [transfer] => [wrapups] => ,12 [tenantid] => 1 [supervisor] => 1005 [username] => Fara [userpass] => 1234 [lastname] => Binti Johari [firstname] => Nurul Farahhin [userlevel] => 2 [usercreated] => 2011-03-26 23:11:56 [lastlogin] => 2012-10-13 20:17:10 [userexten] => [sessionid] => [userstatusid] => 0 [apptype] => webagent [statustimestamp] => 2012-10-13 20:33:21 [lastuserstatusid] => 1 [pqueuetimeout] => 0 [queueroutetype] => 1 [queueroutevalue] => 4 [userdbstatus] => A [criteria_id] => 1 [criteria_title] => Did not demonstrate inappropriate behavior - Zero Tolerance Policy [criteria_rate] => 40 [question_id] => 3 [question_title] => Question 1 [question_type] => y [question_score_y_yes] => 1 [question_score_y_no] => 0 [question_score_y_answer] => [question_score_y] => [question_score_n_a] => [question_score_n_a_value] => [question_score_n_b] => [question_score_n_b_value] => [question_score_n_c] => [question_score_n_c_value] => [question_score_n_d] => [question_score_n_d_value] => [question_score_n_e] => [question_score_n_e_value] => [question_score_n_answer] => [question_score_n] =>)
任何想法如何做到這一點?
什麼是你的數據的結構? I.E. '$ row'裏面是什麼? – 2013-05-14 09:15:25
這是我的$行例如stdClass的對象([RECORD_ID] => 6 [qm_id] => 2 [qm_title] => QM引線2 [record_filename] => abcdefgh.mp3等... – Oscar 2013-05-14 09:18:44