src/Multibyte.php
public static function split($pattern, $string, $limit = -1, $flags = 0)
    {
        $offset_capture = (bool)($flags & PREG_SPLIT_OFFSET_CAPTURE);

        $lengths = self::getSplitLengths($pattern, $string);

        // Substrings
        $parts = [];
        $position = 0;
        $count = 1;
        foreach ($lengths as $length) {
            if (self::isLastPart($length, $flags, $limit, $count)) {
                $parts[] = self::makePart($string, $position, null, $offset_capture);
                return $parts;
            }

            if (self::isPart($length, $flags)) {
                $parts[] = self::makePart($string, $position, $length[0], $offset_capture);
            }

            $position += $length[0];
        }

        return $parts;
    }
public static function split($pattern, $string, $limit = -1, $flags = 0)
    {
        $offset_capture = (bool)($flags & PREG_SPLIT_OFFSET_CAPTURE);

        $lengths = self::getSplitLengths($pattern, $string);

        // Substrings
        $parts = [];
        $position = 0;
        $count = 1;
        foreach ($lengths as $length) {
            if (self::isLastPart($length, $flags, $limit, $count)) {
                $parts[] = self::makePart($string, $position, null, $offset_capture);
                return $parts;
            }

            if (self::isPart($length, $flags)) {
                $parts[] = self::makePart($string, $position, $length[0], $offset_capture);
            }

            $position += $length[0];
        }

        return $parts;
    }
public static function split ( $ pattern , $ string , $ limit = - 1 , $ flags = 0 ) { $ offset_capture = ( bool ) ( $ flags & PREG_SPLIT_OFFSET_CAPTURE ) ; $ lengths = self :: getSplitLengths ( $ pattern , $ string ) ; // Substrings $ parts = [ ] ; $ position = 0 ; $ count = 1 ; foreach ( $ lengths as $ length ) { if ( self :: isLastPart ( $ length , $ flags , $ limit , $ count ) ) { $ parts [ ] = self :: makePart ( $ string , $ position , null , $ offset_capture ) ; return $ parts ; } if ( self :: isPart ( $ length , $ flags ) ) { $ parts [ ] = self :: makePart ( $ string , $ position , $ length [ 0 ] , $ offset_capture ) ; } $ position += $ length [ 0 ] ; } return $ parts ; }
A cross between mb_split and preg_split, adding the preg_split flags
to mb_split.

@param string $pattern
@param string $string
@param int $limit
@param int $flags
@return array
A cross between mb_split and preg_split adding the preg_split flags to mb_split .