src/Arrays/Restructure.php
public static function getDelimitersKeys(array $data, $delimitersNumbers)
    {
        $delimiterKeys = [];

        $elementsNumbers = count($data);

        if ($elementsNumbers <= $delimitersNumbers) {
            throw new RestructureException("Elements number not bigger than delimiter.");
        }

        $portion = ($elementsNumbers - 1) / $delimitersNumbers;
        $portion = (int)$portion;
        $stablePortion = $portion;

        foreach ($data as $key => $value) {
            if (!is_int($key)) {
                throw new RestructureException("Associative array. Expect indexed.");
            }

            if ($key === $portion) {
                $delimiterKeys[] = $key;
                $portion += $stablePortion;
            }
        }

        return $delimiterKeys;
    }
public static function getDelimitersKeys(array $data, $delimitersNumbers)
    {
        $delimiterKeys = [];

        $elementsNumbers = count($data);

        if ($elementsNumbers <= $delimitersNumbers) {
            throw new RestructureException("Elements number not bigger than delimiter.");
        }

        $portion = ($elementsNumbers - 1) / $delimitersNumbers;
        $portion = (int)$portion;
        $stablePortion = $portion;

        foreach ($data as $key => $value) {
            if (!is_int($key)) {
                throw new RestructureException("Associative array. Expect indexed.");
            }

            if ($key === $portion) {
                $delimiterKeys[] = $key;
                $portion += $stablePortion;
            }
        }

        return $delimiterKeys;
    }
public static function getDelimitersKeys ( array $ data , $ delimitersNumbers ) { $ delimiterKeys = [ ] ; $ elementsNumbers = count ( $ data ) ; if ( $ elementsNumbers <= $ delimitersNumbers ) { throw new RestructureException ( "Elements number not bigger than delimiter." ) ; } $ portion = ( $ elementsNumbers - 1 ) / $ delimitersNumbers ; $ portion = ( int ) $ portion ; $ stablePortion = $ portion ; foreach ( $ data as $ key => $ value ) { if ( ! is_int ( $ key ) ) { throw new RestructureException ( "Associative array. Expect indexed." ) ; } if ( $ key === $ portion ) { $ delimiterKeys [ ] = $ key ; $ portion += $ stablePortion ; } } return $ delimiterKeys ; }
Allow to detect arrays keys, that divide array into portions by delimiter number.

@param array $data
@param $delimitersNumbers
@return array
@throws RestructureException
Allow to detect arrays keys that divide array into portions by delimiter number .