protected function splitContentMeta($data)
    {
        // Remove Byte Order Mark (BOM)
        $data = preg_replace('/\x{EF}\x{BB}\x{BF}/', '', $data);

        // Pattern for detecting a metadata separator (---)
        // Using ^ and $ in this way requires the PCRE_MULTILINE modifier
        $pattern = '/' // Pattern start
            . '^'       // Beginning of line
            . '---'     // Literal ---
            . '\\s*'    // Zero or more whitespace characters
            . '$'       // End of line
            . '/m';     // Pattern end, PCRE_MULTILINE modifier

        // Separate the meta-data from the content
        $data = trim($data);

        if (
            (substr($data, 0, 3) === '---') &&
            (preg_match($pattern, $data, $matches, PREG_OFFSET_CAPTURE, 3))
        ) {
            $pos = $matches[0][1];
            $len = strlen($matches[0][0]);

            $meta = trim(substr($data, 3, $pos - 3));
            $content = trim(substr($data, $pos + $len));
        }
        else {
            $content = $data;
            $meta = null;
        }

        return [$content, $meta];
    }
protected function splitContentMeta($data)
    {
        // Remove Byte Order Mark (BOM)
        $data = preg_replace('/\x{EF}\x{BB}\x{BF}/', '', $data);

        // Pattern for detecting a metadata separator (---)
        // Using ^ and $ in this way requires the PCRE_MULTILINE modifier
        $pattern = '/' // Pattern start
            . '^'       // Beginning of line
            . '---'     // Literal ---
            . '\\s*'    // Zero or more whitespace characters
            . '$'       // End of line
            . '/m';     // Pattern end, PCRE_MULTILINE modifier

        // Separate the meta-data from the content
        $data = trim($data);

        if (
            (substr($data, 0, 3) === '---') &&
            (preg_match($pattern, $data, $matches, PREG_OFFSET_CAPTURE, 3))
        ) {
            $pos = $matches[0][1];
            $len = strlen($matches[0][0]);

            $meta = trim(substr($data, 3, $pos - 3));
            $content = trim(substr($data, $pos + $len));
        }
        else {
            $content = $data;
            $meta = null;
        }

        return [$content, $meta];
    }
protected function splitContentMeta ( $ data ) { // Remove Byte Order Mark (BOM) $ data = preg_replace ( '/\x{EF}\x{BB}\x{BF}/' , '' , $ data ) ; // Pattern for detecting a metadata separator (---) // Using ^ and $ in this way requires the PCRE_MULTILINE modifier $ pattern = '/' // Pattern start . '^' // Beginning of line . '---' // Literal --- . '\\s*' // Zero or more whitespace characters . '$' // End of line . '/m' ; // Pattern end, PCRE_MULTILINE modifier // Separate the meta-data from the content $ data = trim ( $ data ) ; if ( ( substr ( $ data , 0 , 3 ) === '---' ) && ( preg_match ( $ pattern , $ data , $ matches , PREG_OFFSET_CAPTURE , 3 ) ) ) { $ pos = $ matches [ 0 ] [ 1 ] ; $ len = strlen ( $ matches [ 0 ] [ 0 ] ) ; $ meta = trim ( substr ( $ data , 3 , $ pos - 3 ) ) ; $ content = trim ( substr ( $ data , $ pos + $ len ) ) ; } else { $ content = $ data ; $ meta = null ; } return [ $ content , $ meta ] ; }
Parse metadata and content

@param  string $data
@return array
Parse metadata and content