Take 8 words and output all possibile phrazes

hi there

I have a form that i can input 8 words but im not sure on how to output the 8 into all possible phrases for example

say the words are just     I am not sure

not sure
i sure
am not sure
i am not sure

and so on

Any one got any suggestions on how to do this

best regards
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

This code was not written by me, but it almost does what you want it to. I hope that you can do the part that is missing, because this sounds like homework, so you should be doing it yourself.


perm(array("I ", "am ", "not ", "sure "));

function PrintPerm() {
global $yourArr,$pArr,$n;

for ($i=1; $i <= $n; $i++)
  echo $yourArr[$pArr[$i]-1];
echo "<br>";


function swapThem($i,$j) {
global $pArr;

$temp = $pArr[$i];
$pArr[$i] = $pArr[$j];
$pArr[$j] = $temp;

function NextPerm() {
global $pArr,$n;

$k = $n-1;
while ($pArr[$k] > $pArr[$k+1]) $k--;
if ($k == 0) return(0);
$j = $n;
while ($pArr[$k] > $pArr[$j]) $j--;
$r = $n;
$s = $k+1;
while ($r > $s)

function perm($array) {
global $yourArr,$pArr,$n;
//Put your array here

$n = count($yourArr);

for ($i=0; $i <= $n; $i++) $pArr[$i]=$i; //The permutation array.

//Print the array values
while (NextPerm()); //Permute and print

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
thats all good except for 3 undefined variable errors....It shouldn't have..


..up the top because it is not a class, therefore they do not need to be predefined and it works perfectly without them.

/ Zac Charles
Sounds good, but you shouldn't be getting errors anyway (I don't).
thats a configuration question.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.