Array coding problem

Hi all i am creating a combinations program that will take in a users list of numbers and stores them in an array. I want to find out all possible combinations of the elements in the array and when i run the program i would like to have an array for each new combination for example if i have 1,2,3,4 in my array then i should have 15 arrays ie 1, 2, 3,4 12,13,14,23,24,34,123,124,234,241,1234 so far ive managed to create the combination function and when i pass this to the findElements function i can get the values for each iteration. see below;

111
201

111
301

201
301

111
201
301

full program here

<?php
function calculateNumberOfCombinations($newArray, $len)
{
    if ($len > count($newArray))
        return 'error';
    $out = array();
    if ($len == 1) {
        foreach ($newArray as $v)
            $out[] = array($v);
        return $out;
    }
    $len--;
    while (count($newArray) > $len) {
        $b = array_shift($newArray);
        $c = calculateNumberOfCombinations($newArray, $len);
        foreach ($c as $v) {
            array_unshift($v, $b);
            $out[] = $v;
        }
    }
    return $out;
}
$numberOfCombos = array(111, 201, 301);
$allArrays = array();
$newArray=array();

for($count=2;$count<=count($numberOfCombos); $count++)
{
    //counted at 2 as i dont have to worry about singles
    $newArray = calculateNumberOfCombinations($numberOfCombos, $count);   
    $allArrays[] = $newArray;
     
}

findArray($allArrays);
function findArray($allArrays)
{
    if (!is_array($allArrays))
        die('not array');
    foreach ($allArrays as $value) {
        if (is_array($value)) {
            findArray($value);
        } else {
            echo $value.'';
            //need to be able to place each value into a new array for each iteration
        }
        echo '<br />';
    }
}

?>

Grateful for any help and advice

Hi and welcome to SP.
So what exactly is your problem?

as stated i need to place the result of each iteration of the foreach loop in the findArray function into a new array so for exampe the initial array 1,2,3, will give me the following new arrays (1,2) (2,3) (1,2,3)

thanks