View Single Post
Old 01-23-2022, 01:50 PM  
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,141
Array question in php output

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:

Quote:
$res[] = $w
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?
__________________
SOMETHING EXTREME IS COMING SOON!
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote