bubblegumoff
Новичок
Здравствуйте! Искал в инете, но так и не смог найти толковых ответов..
Несколько дней уже ломаю голову.
Есть массив
$array = array("one", "two", "three");
Нужно вывести все возможные варианты в новый массив с указанием числа создаваемых фраз. Например
$k = 4;
$new_array = array(
array("one", "one", "one", "one"),
array("one", "one", "one", "two"),
array("one", "one", "one", "three"),
array("one", "one", "one", "four"),
array("one", "one", "two", "one"),
array("one", "one", "two", "two"),
array("one", "one", "two", "three"),
array("one", "one", "two", "four"),
array("one", "one", "three", "one"),
array("one", "one", "three", "two"),
array("one", "one", "three", "three"),
array("one", "one", "three", "four"),
array("one", "one", "four", "one"),
array("one", "one", "four", "two"),
array("one", "one", "four", "three"),
array("one", "one", "four", "four")
...
...
);
И заканчивается, соответственно, как-то так
$new_array = array(
...
...
array("four", "four", "three", "three"),
array("four", "four", "three", "four"),
array("four", "four", "four", "one"),
array("four", "four", "four", "two"),
array("four", "four", "four", "three"),
array("four", "four", "four", "four")
)
Несколько дней уже ломаю голову.
Есть массив
$array = array("one", "two", "three");
Нужно вывести все возможные варианты в новый массив с указанием числа создаваемых фраз. Например
$k = 4;
$new_array = array(
array("one", "one", "one", "one"),
array("one", "one", "one", "two"),
array("one", "one", "one", "three"),
array("one", "one", "one", "four"),
array("one", "one", "two", "one"),
array("one", "one", "two", "two"),
array("one", "one", "two", "three"),
array("one", "one", "two", "four"),
array("one", "one", "three", "one"),
array("one", "one", "three", "two"),
array("one", "one", "three", "three"),
array("one", "one", "three", "four"),
array("one", "one", "four", "one"),
array("one", "one", "four", "two"),
array("one", "one", "four", "three"),
array("one", "one", "four", "four")
...
...
);
И заканчивается, соответственно, как-то так
$new_array = array(
...
...
array("four", "four", "three", "three"),
array("four", "four", "three", "four"),
array("four", "four", "four", "one"),
array("four", "four", "four", "two"),
array("four", "four", "four", "three"),
array("four", "four", "four", "four")
)