Combination - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of Combination.php
- <?php
- class Combination{
- public static $n=1;
- static function combinations2(array $arr, $len, $startPosition, array $result):void{
- if ($len == 0){
- print(self::$n." : ".$result[0].$result[1].$result[2]);
- echo("\n");
- self::$n++;
- return;
- }
- for ( $i = $startPosition; $i <= (count($arr)-$len); $i++){
- $result[count($result) - $len] = $arr[$i];
- // print_r($result);
- Combination::combinations2($arr, $len-1, $i+1, $result);
- }
- }
- }
- $arr = ["1","2","3","4","5","6"];
- $tab = ["","",""];
- //print_r($arr);
- $comb=new Combination();
- $comb->combinations2( $arr, 3, 0, $tab );
File Description
- Combination
- PHP Code
- 20 Apr-2022
- 733 Bytes
You can Share it:
Latest PHP Pastes