So I have a basic script written to output word variables (code below) but Its displaying the following when it runs:
[0] => oneone
[1] => onetwo
[2] => twotwo
[3] => twoone
Any pointers on how I can remove the [X] = > part from the output so the list is clean?
Here is the code I'm working with:
Quote:
<?php
function permutations($arr,$n)
{
$res = array();
foreach ($arr as $w)
{
if ($n==1) $res[] = $w;
else
{
$perms = permutations($arr,$n-1);
foreach ($perms as $p)
{
$res[] = $w."".$p;
}
}
}
return $res;
}
// Your array
$words = file('numbers.txt',FILE_IGNORE_NEW_LINES);
// Get permutation by groups of 2 elements
$pe = permutations($words,2);
// Print it out
echo "<pre>";
preg_replace('([0-9]+)', '$1', $array );
$v = print_r($pe,true);
echo $v;
echo "<pre>";
?>
|
I was thinking it had something to do with this part:
But I changed it a few times and it didnt like the code.
Any help/pointers would be appreciated, It seems like a simple fix?
