public static function flatten($input, $context = null, $options = null)
    {
        $options = self::mergeOptions($options);

        $input = self::expand($input, $options);

        $processor = new Processor($options);
        $flattened = $processor->flatten($input);

        if (null === $context) {
            return $flattened;
        }

        return self::doCompact($flattened, $context, $options, true);
    }
public static function flatten($input, $context = null, $options = null)
    {
        $options = self::mergeOptions($options);

        $input = self::expand($input, $options);

        $processor = new Processor($options);
        $flattened = $processor->flatten($input);

        if (null === $context) {
            return $flattened;
        }

        return self::doCompact($flattened, $context, $options, true);
    }
public static function flatten ( $ input , $ context = null , $ options = null ) { $ options = self :: mergeOptions ( $ options ) ; $ input = self :: expand ( $ input , $ options ) ; $ processor = new Processor ( $ options ) ; $ flattened = $ processor -> flatten ( $ input ) ; if ( null === $ context ) { return $ flattened ; } return self :: doCompact ( $ flattened , $ context , $ options , true ) ; }
Flatten a JSON-LD document

Both the document and the context can be supplied directly as string,
by passing a file path, or by passing a URL.

Usage:

$flattened = JsonLD::flatten('document.jsonld');
print_r($flattened);

It is possible to configure the flattening process by setting the options
parameter accordingly. Available options are:

<dl>
<dt>base</dt>
<dd>The base IRI of the input document.</dd>

<dt>expandContext</dt>
<dd>An optional context to use additionally to the context embedded
in input when expanding the input.</dd>

<dt>graph</dt>
<dd>The graph whose flattened representation should be returned.
The default graph is identified by {@link DEFAULT_GRAPH} and the
merged dataset graph by {@link MERGED_GRAPH}. If <em>null</em> is
passed, all graphs will be returned.</dd>

<dt>documentLoader</dt>
<dd>The document loader.</dd>
</dl>

The options parameter might be passed as associative array or as
object.

@param string|JsonObject|array      $input   The JSON-LD document to flatten.
@param null|string|JsonObject|array $context The context to compact the
flattened document. If
<em>null</em> is passed, the
result will not be compacted.
@param null|array|JsonObject        $options Options to configure the
flattening process.

@return JsonObject The flattened JSON-LD document.

@throws JsonLdException

@api
Flatten a JSON - LD document