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"; }
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
<div class="row"> <div class="col s12 m6 grid"> <figure class="effect-honey"> <img src="A.jpg" alt="B C"/> <figcaption> <h2>B<span>C</span> <i>D</i></h2> </figcaption> </figure> </div> <div class="col s12 m6 grid"> <figure class="effect-honey"> <img src="E.jpg" alt="F G"/> <figcaption> <h2>F<span>G</span> <i>H</i></h2> </figcaption> </figure> </div> </div> <div class="row"> <div class="col s12 m6 grid"> <figure class="effect-honey"> <img src="I.jpg" alt="J K"/> <figcaption> <h2>J<span>K</span> <i>L</i></h2> </figcaption> </figure> </div> </div>

preferences:
102.22 ms | 2128 KiB | 4 Q