计算数字的最大输出

I am creating a filter which uses multiple input value to compare with each other and find some matches if they have some common data Example:

if i use 4 inputs with values a,b,c,d then maximum compression can come something like this

Input: 1-2
Input: 1-3
Input: 1-4
Input: 2-3
Input: 2-4
Input: 3-4

here we not included 1-1,2-2,3-3 and 4-4 also 2-1,3-1... cause 1-2 or 2-1 have same compassion and that is a-b and b-a.. Now i want to create this output for given numbers of output...so i am looking for some Php or Jquery solution to create a loop and find output.

This is called handshaking problem, studied in out school time.

<?php
$peoples = ["a","b","c","d"];
for($i=0;$i<count($peoples);$i++){
  for($j=$i+1;$j<count($peoples);$j++){
    echo "$peoples[$i] will handshake with $peoples[$j]
";
  }
}
?>

Check demo : https://eval.in/608543

Try this:

$size = 4;//number of inputs
$output = [];
for($i=1;$i<$size;$i++){
    for($j=$i+1;$j<=$size;$j++){
        $output[] = "Input: $i-$j 
";
    }
}
echo implode("",$output);

Live demo

Hi You can also try this

<?php
$data = array("a","b","c","d");
for($i=0;$i<count($data);$i++){
  for($j=$i+1;$j<count($data);$j++){
    echo "input :" ."$data[$i]"." - "."$data[$j]"."</br>";
  }
}
?>