VersionPress\Storages\Serialization\IniSerializer::expandArrays PHP Method

expandArrays() private static method

[ 'key' => 'value', 'another_key[0]' => 'value', 'another_key[1]' => 'another value', ] to [ 'key' => 'value', 'another_key' => [ 0 => 'value', 1 => 'another value', ] ]
private static expandArrays ( $deserialized ) : array
$deserialized
return array
    private static function expandArrays($deserialized)
    {
        $dataWithExpandedArrays = [];
        foreach ($deserialized as $key => $value) {
            if (is_array($value)) {
                $value = self::expandArrays($value);
            }
            // https://regex101.com/r/bA6uD2/3
            if (preg_match("/(.*)\\[([^]]+)\\]\$/", $key, $matches)) {
                $originalKey = $matches[1];
                $subkey = $matches[2];
                $dataWithExpandedArrays[$originalKey][$subkey] = $value;
            } else {
                $dataWithExpandedArrays[$key] = $value;
            }
        }
        return $dataWithExpandedArrays;
    }