flattenList() public static method

Opposite of expandList(). So array('Some' => array('Deep' => array('Value'))) becomes Some.Deep.Value. Note that primarily only string should be used. However, boolean values are casted to int and thus both boolean and integer values also supported.
public static flattenList ( array $data, string $separator = '.' ) : array
$data array
$separator string
return array
Example #1
0
 /**
  * UtilityTest::testFlatten()
  *
  * @return void
  */
 public function testFlatten()
 {
     $is = ['Some' => ['Deep' => ['Value1', 'Value2'], 'Even' => ['Deeper' => ['Nested' => ['Value']]]], 'Empty' => [''], '0' => ['1' => ['2']], '' => ['EmptyString']];
     $result = Utility::flattenList($is);
     $expected = ['Some.Deep.Value1', 'Some.Deep.Value2', 'Some.Even.Deeper.Nested.Value', 'Empty.', '0.1.2', '.EmptyString'];
     $this->assertSame($expected, $result);
     // Test integers als booleans
     $is = ['Some' => ['Deep' => [true], 'Even' => ['Deeper' => ['Nested' => [false, true]]]], 'Integer' => ['Value' => [-3]]];
     $result = Utility::flattenList($is);
     $expected = ['Some.Deep.1', 'Some.Even.Deeper.Nested.0', 'Some.Even.Deeper.Nested.1', 'Integer.Value.-3'];
     $this->assertSame($expected, $result);
 }