mironovdv/crossword

Crossword generator

dev-master 2016-09-14 14:16 UTC

This package is not auto-updated.

Last update: 2021-04-17 10:14:57 UTC


README

Php crossword generator

Column base crossword

$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'],
// ]

Row base crossword

$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'],
// ]

Random crossword

$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', ' ', ' ', ' ', ' ', ' '],
//   [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
//   [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
//   [' ', ' ', ' ', ' ', '', ' ', ' ', ' ', ' '],
// ]