Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. $length = $_GET['length'];
  2. $proto = $_GET['proto'];
  3. $dead = $_GET['dead'];
  4.  
  5. $dict = file("wordlist/" . $length . "_letters.txt", FILE_IGNORE_NEW_LINES);
  6.  
  7. $exp = '/^' . str_replace('*', '\w{1}', $proto) . '$/u';
  8. $words = array_filter($dict, function($v) use ($exp, $dead) {
  9. $dw = true;
  10. foreach (array_diff(preg_split('//u', $dead), ['']) as $d) {
  11. if (preg_match('/' . $d . '/u', $v)) {
  12. $dw = false;
  13. break;
  14. };
  15. }
  16. return (preg_match($exp, $v) && $dw);
  17. });
  18.  
  19. $letters = [];
  20. foreach ($words as $v) {
  21. foreach (array_diff(preg_split('//u', $v), ['']) as $w) {
  22. $letters[] = $w;
  23. }
  24. }
  25.  
  26. $ret = ['words' => $words, 'letters' => $letters];
  27. var_dump($ret);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement