PHP code example of amercier / rectangular-mozaic
1. Go to this page and download the library: Download amercier/rectangular-mozaic library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
amercier / rectangular-mozaic example snippets
use \RectangularMozaic\Generator as Mozaic;
use \RectangularMozaic\Cell;
$tilesNumber = 20;
$columns = 5;
$grid = Mozaic::generate($tilesNumber, $columns);
echo '<table>';
$i = 1;
foreach ($grid->getCells() as $row) {
echo '<tr>';
foreach ($row as $cell) {
switch ($cell) {
case Cell::SMALL:
echo '<td>' . $i . '</td>';
break;
case Cell::TALL_TOP:
echo '<td rowspan="2">' . $i . '</td>';
break;
case Cell::TALL_BOTTOM:
break; // do nothing
case Cell::WIDE_LEFT:
echo '<td colspan="2">' . $i . '</td>';
break;
case Cell::WIDE_RIGHT:
break; // do nothing
}
$i += 1;
}
echo '</tr>';
}
echo '</table>';