1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-11 00:54:49 +02:00

Add: e_parse::toFlatArray() and e_parse::fromFlatArray()

Utility functions to convert multi-dimensional arrays to slash-delimited
single-dimensional arrays and vice versa
This commit is contained in:
Nick Liu
2021-04-17 02:56:12 -05:00
parent f6f63b680f
commit ce7f3b5d56
3 changed files with 99 additions and 29 deletions

View File

@@ -583,6 +583,44 @@ while($row = $sql->fetch())
}
*/
public function testToFlatArray()
{
$input = [
'a' => [
'b' => [
'c' => 'value',
],
],
];
$expected = [
'prepend/xyza/b/c' => 'value'
];
$tp = $this->tp;
$actual = $tp->toFlatArray($input, 'prepend/xyz');
$this->assertSame($expected, $actual);
}
public function testFromFlatArray()
{
$input = [
'prepend/xyza/b/c' => 'value'
];
$expected = [
'a' => [
'b' => [
'c' => 'value',
],
],
];
$tp = $this->tp;
$actual = $tp->fromFlatArray($input, 'prepend/xyz');
$this->assertSame($expected, $actual);
}
public function testToForm()
{