generate functionSat, 15 Apr 2023

tabla de ajedrez

<?php function tablaAjedrez($ancho=8, $alto=8) { $tablero = ""; for ($x=1; $x<=$alto; $x++) { for ($y=1; $y<=$ancho; $y++) { $color = $x%2 == $y%2 ? "white" : "black"; $tablero .= "<div class=\"square $color\">$x,$y</div>"; } } echo "<div class=\"chessboard\">$tablero</div>"; } tablaAjedrez(5,5); ?>

Questions about programming?Chat with your personal AI assistant