0 && isset($columns[$col][$row - 1]) && $columns[$col][$row - 1] === $imagePath) {
return false;
}
if ($col > 0) {
// Gauche
if (isset($columns[$col - 1][$row]) && $columns[$col - 1][$row] === $imagePath) {
return false;
}
// Diagonale Haut-Gauche
if ($row > 0 && isset($columns[$col - 1][$row - 1]) && $columns[$col - 1][$row - 1] === $imagePath) {
return false;
}
// Diagonale Bas-Gauche
if (isset($columns[$col - 1][$row + 1]) && $columns[$col - 1][$row + 1] === $imagePath) {
return false;
}
}
return true;
}
// Construction de la structure de données
for ($col = 0; $col < $nbColumns; $col++) {
$columns[$col] = [];
for ($row = 0; $row < $rowsPerColumn; $row++) {
shuffle($images);
$placed = false;
foreach ($images as $img) {
if (canPlace($columns, $col, $row, $img['chemin'])) {
$columns[$col][$row] = $img['chemin'];
$placed = true;
break;
}
}
if (!$placed && !empty($images)) {
$columns[$col][$row] = $images[0]['chemin'];
}
}
}
// Affichage manuel sans classes Bootstrap conflictuelles
for ($col = 0; $col < $nbColumns; $col++): ?>