Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私のウェブサイトでは、学生の詳細をページに表示したいと考えています。設計目的でテーブルを使用しています。私が必要としているのは、各行に 2 人の生徒を表示したいということです。したがって、データベースに合計 10 人の生徒がいる場合、表示ページには 5 つの行があり、各行には 2 人の生徒が含まれているはずです。
どうすればこれを達成できますか?
$students = Array('S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'S9', 'S10'); $html = '<table>'; for ($i = 0; $i<count($students); $i+=2) { $html.= '<tr> <td>'.$students[$i].'</td> <td>'.$students[$i+1].'</td> </tr>'; } $html.= '</table>';