$way = array(a,b,c,d...); //массив с элементами $result = array(a => array(b,c,d), b => array(a,c,d),...); // что нужно получить 

How can this be implemented in php?

    1 answer 1

     <? $way = array(a,b,c,d); $result = array(); foreach($way as $i => $data1){ $result[$i] = array(); foreach($way as $j => $data2) if($i != $j) $result[$i][] = $j; } ?> 
    • corrected the question - user193361
    • @ user193361 corrected the answer - Mihanik71