3v4l.org

run code in 500+ PHP versions simultaneously
<?php $team = [ ['image' => 'A.jpg', 'fname' => 'B', 'lname' => 'C', 'position' => 'D'], ['image' => 'E.jpg', 'fname' => 'F', 'lname' => 'G', 'position' => 'H'], ['image' => 'I.jpg', 'fname' => 'J', 'lname' => 'K', 'position' => 'L'] ]; $pairs = array_chunk($team, 2); foreach ($pairs as $pair) { echo "<div class=\"row\">\n"; foreach ($pair as $player) { echo "\t<div class=\"col s12 m6 grid\">\n"; echo "\t\t<figure class=\"effect-honey\">\n"; echo "\t\t\t<img src=\"{$player['image']}\" alt=\"{$player['fname']} {$player['lname']}\"/>\n"; echo "\t\t\t<figcaption>\n"; echo "\t\t\t\t<h2>{$player['fname']}<span>{$player['lname']}</span> <i>{$player['position']}</i></h2>\n"; echo "\t\t\t</figcaption>\n"; echo "\t\t</figure>\n"; echo "\t</div>\n"; } echo "</div>\n"; }

preferences:
46.58 ms | 2126 KiB | 5 Q