Php to find a combination of all A (4pr 2)?

for example, if you want to get AB, AC, BA, BC, CA, and CB.
but the number of ABC varies, ask the algorithm expert, how to write a function to get the array of all cases?

Php
Mar.03,2021

No code is only available for other An2 models to write a general

.
function An2(array $arr)
{
    $out = [];
    for ($i = 0; $i < count($arr) - 1; $i PP) {
        for ($j = $i + 1; $j < count($arr); $jPP) {
            $out[] = [$arr[$i], $arr[$j]];
            $out[] = [$arr[$j], $arr[$i]];
        }
    }
    return $out;
}

print_r(An2([1,2]));
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf4101-3a275.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf4101-3a275.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?