flattenKeysRecursively() публичный статический метод

Example: $array = array( 'customer' => array( 'name' => 'Name', 'phone' => '123456789' ), 'other' => array( 'ids_map' => array( '1qaz' => 'qaz', '2wsx' => 'wsx' ), 'first' => array( 'second' => array( 'third' => 'some value' ) ) ) ); $flatten = Arrays::flattenKeysRecursively($array) Result: Array ( [customer.name] => Name [customer.phone] => 123456789 [other.ids_map.1qaz] => qaz [other.ids_map.2wsx] => wsx [other.first.second.third] => some value )
public static flattenKeysRecursively ( array $array ) : array
$array array
Результат array
Пример #1
0
 public function hasEqualKeysRecursively(array $array)
 {
     $currentArrayFlatten = array_keys(Arrays::flattenKeysRecursively($this->actual));
     $arrayFlatten = array_keys(Arrays::flattenKeysRecursively($array));
     AssertAdapter::assertSame(array_diff($currentArrayFlatten, $arrayFlatten), array_diff($arrayFlatten, $currentArrayFlatten));
     return $this;
 }
Пример #2
0
 /**
  * @test
  */
 public function shouldCreateArrayWithFlattenKeys()
 {
     //given
     $array = array('customer' => array('name' => 'Name', 'phone' => '123456789'), 'other' => array('ids_map' => array('1qaz' => 'qaz', '2wsx' => 'wsx'), 'first' => array('second' => array('third' => 'some value'))));
     //when
     $flatten = Arrays::flattenKeysRecursively($array);
     //then
     $expected = array('customer.name' => 'Name', 'customer.phone' => '123456789', 'other.ids_map.1qaz' => 'qaz', 'other.ids_map.2wsx' => 'wsx', 'other.first.second.third' => 'some value');
     $this->assertEquals($expected, $flatten);
 }