util-transformer
Documentation / Flatten Decoder
Introduction
The FlattenDecoder expands array with flattened keys to nested array.
Using the decoder
// Convert to anything
$decoder = new FlattenDecoder('_');
$flattened = [
'a1_b1_c1' => 111,
'a1_b1_c2' => 112,
'a2' => 2,
];
$decoder->canTransform($flattened); // -> bool
$result = $decoder->transform($flattened); // -> mixed output
/*
$result => [
'a1' => [
'b1' => [
'c1' => 111,
'c2' => 112,
],
],
'a2' => 2,
];
*/
Requirements
PHP
^8.1Documentation
Overview TypesCodecs
FlattenDecoderJsonDecoderConverters
BasicTypeDateTimeEnumJsonSerializableReadableReversedReadableStringableThrowableResolvers
ChainedFirstMatchRecursionStringWrappers
SymfonyNormalizer