if i give a string 'ab' i need all combinations of the string generated
like
aa
ab
ba
bb

if i give abc i need
aaa
aab
aac
aba
abb
abc
and so on...
here i dunno the length of the string

    I had a script not exactly the same as what you want.. But it got names.. And it got everyones name and matched them next to each other.. There wasnt any that were the same so no..

    mac n mac etc..

    But basically what i did was
    Have each name in an array
    So for you

    a and a

    have array
    $array = array("a","b");

    From there you''ll need to have a foreach statement.. Then another in it. In the second foreach you'd display the data.. If i ever find the script.. Ill show you exactly what i did.

      This works ...

      // Pass a string of chars e.g. "abc"
      // Returns array of combinations
      function combination($s){
      	$str_len = strlen($s);
      	for($i = 0; $i < $str_len; $i++){
      		$a[] = substr($s, $i, 1);
      	}
      	$b[] = ""; // Need one empty element to start
      	for($k = 0; $k < $str_len; $k++){
      		$r = array();
      		for($i = 0; $i < $str_len; $i++){
      			for($j = 0; $j < count($b); $j++){
      				$r[] = $a[$i].$b[$j];
      			}
      		}
      		$b = $r;
      	}
      	return $b;
      }
      
      $r = combination("123");
      
      echo "[".join(", ", $r)."]";
      
        Write a Reply...