<?php
$name = "заяц";
$letters = preg_split('//u', $name, -1, PREG_SPLIT_NO_EMPTY
);
function ano($found, $letters) {
echo $found . "\n";
} else {
foreach ($letters as $num => $letter) {
$tempArray = $letters;
$tempAno = $found . $letter;
ano($tempAno, $tempArray);
}
}
}
$here = "";
ano ($here, $letters);
PD9waHAKZXJyb3JfcmVwb3J0aW5nKC0xKTsKCiRuYW1lID0gItC30LDRj9GGIjsKCiRsZXR0ZXJzID0gcHJlZ19zcGxpdCgnLy91JywgJG5hbWUsIC0xLCBQUkVHX1NQTElUX05PX0VNUFRZKTsKCgpmdW5jdGlvbiBhbm8oJGZvdW5kLCAkbGV0dGVycykgewoJaWYgKGVtcHR5KCRsZXR0ZXJzKSl7CgkJZWNobyAkZm91bmQgLiAiXG4iOwoJfSBlbHNlIHsKCQlmb3JlYWNoICgkbGV0dGVycyBhcyAkbnVtID0+ICRsZXR0ZXIpIHsKCQkJJHRlbXBBcnJheSA9ICRsZXR0ZXJzOwoJCQkkdGVtcEFubyA9ICRmb3VuZCAuICRsZXR0ZXI7CgkJCXVuc2V0KCR0ZW1wQXJyYXlbJG51bV0pOwoJCQlhbm8oJHRlbXBBbm8sICR0ZW1wQXJyYXkpOwoJCX0KCX0KCn0KJGhlcmUgPSAiIjsKCmFubyAoJGhlcmUsICRsZXR0ZXJzKTs=