0

Let's assume the following -simplified- string: 'Xyy'.

Starting from this, I would like to exchange all 'y' with all possible combinations of 0 and 1 (also simplified).

Accordingly, the result should be: X00, X01, X10, X11.

Thank you!

1 Answers1

0

Something like this:

function gen() {      
    for($i=0;$i<=1;$i++) { 
        for($j=0;$j<=1;$j++) {    
            yield "X{$i}{$j}";     
        } 
    }                                                                 

}

and invoke it like so:

   foreach(gen() as $val) {                     
       echo $val . " ";    
   }  
Bolek Tekielski
  • 1,194
  • 2
  • 10
  • 25