atomino/util-dot-notation

Array dot notation converter

1.0 2022-03-17 12:05 UTC

This package is auto-updated.

Last update: 2024-11-17 19:09:03 UTC


README

DotNotation::extract(array $flattenedData):array;
DotNotation::flatten(array $hierarchicalData):array;

DotNotation converts hierarchical arrays between hierarchical format and dot-separated format.

Flattened dot-separated format:

$data = [
  "alfa.beta.gamma" => "1",
  "alfa.beta.delta" => "2",
  "alfa.omega" => "3"
];

Hierarchical data extracted from the dot-separated format:

$data = [
  "alfa" => [
    "beta" => [
      "gamma" => 1,
      "delta" => 2
    ],
    "omega" => 3
  ]
];