PHP code example of dmathews / crossword
1. Go to this page and download the library: Download dmathews/crossword 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/ */
dmathews / crossword example snippets
$words = ['hello', 'on', 'hi'];
$crossword = new \Crossword\Crossword(2, 5, $words);
$isGenerated = $crossword->generate(\Crossword\Generate\Generate::TYPE_BASE_LINE_COLUMN);
print_r($crossword->toArray());
// [
// ['h', 'i'],
// ['e', ' '],
// ['l', ' '],
// ['l', ' '],
// ['o', 'n'],
// ]
$words = ['hello', 'on', 'hi'];
$crossword = new \Crossword\Crossword(5, 2, $words);
$isGenerated = $crossword->generate(\Crossword\Generate\Generate::TYPE_BASE_LINE_ROW);
print_r($crossword->toArray());
// [
// ['h', 'e', 'l', 'l', 'o'],
// ['i', ' ', ' ', ' ', 'n'],
// ]
$words = ['ubuntu', 'bower', 'seed', 'need'];
$crossword = new \Crossword\Crossword(9, 9, $words);
$isGenerated = $crossword->generate(\Crossword\Generate\Generate::TYPE_RANDOM);
print_r($crossword->toArray());
// [
// [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
// [' ', ' ', 'u', 'b', 'u', 'n', 't', 'u', ' '],
// [' ', ' ', ' ', 'o', ' ', 'e', ' ', ' ', ' '],
// [' ', ' ', ' ', 'w', ' ', 'e', ' ', ' ', ' '],
// [' ', ' ', 's', 'e', 'e', 'd', ' ', ' ', ' '],
// [' ', ' ', ' ', 'r', ' ', ' ', ' ', ' ', ' '],
// [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
// [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
// [' ', ' ', ' ', ' ', '', ' ', ' ', ' ', ' '],
// ]