Skip to content

Instantly share code, notes, and snippets.

@Taluu
Created March 6, 2014 16:17
Show Gist options
  • Select an option

  • Save Taluu/9393232 to your computer and use it in GitHub Desktop.

Select an option

Save Taluu/9393232 to your computer and use it in GitHub Desktop.
<?php
const WORD = 'MY FANCY WORD';
const JOKER = '\'';
$parts = [];
$i = 0;
foreach (str_split(strrev(WORD)) as $word) {
$parts[pow(2, $i++)] = $word;
}
for ($i = 0; $i < pow(2, count($parts)); ++$i) {
$word = '';
foreach ($parts as $flag => $letter) {
$word .= $i & $flag ? $letter : JOKER;
}
echo strrev($word) . "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment