public static function exchange(array &$elements, $indexA, $indexB)
    {
        $count = count($elements);

        if (($indexA < 0 || $indexA > ($count - 1))
            || $indexB < 0
            || $indexB > ($count - 1)
        ) {
            throw new IndexOutOfBoundsException();
        }

        $temp = $elements[$indexA];

        $elements[$indexA] = $elements[$indexB];

        $elements[$indexB] = $temp;
    }
public static function exchange(array &$elements, $indexA, $indexB)
    {
        $count = count($elements);

        if (($indexA < 0 || $indexA > ($count - 1))
            || $indexB < 0
            || $indexB > ($count - 1)
        ) {
            throw new IndexOutOfBoundsException();
        }

        $temp = $elements[$indexA];

        $elements[$indexA] = $elements[$indexB];

        $elements[$indexB] = $temp;
    }
public static function exchange ( array & $ elements , $ indexA , $ indexB ) { $ count = count ( $ elements ) ; if ( ( $ indexA < 0 || $ indexA > ( $ count - 1 ) ) || $ indexB < 0 || $ indexB > ( $ count - 1 ) ) { throw new IndexOutOfBoundsException ( ) ; } $ temp = $ elements [ $ indexA ] ; $ elements [ $ indexA ] = $ elements [ $ indexB ] ; $ elements [ $ indexB ] = $ temp ; }
Exchange two elements in an array.

@param array $elements
@param int $indexA
@param int $indexB

@throws IndexOutOfBoundsException
Exchange two elements in an array .