vendredi 8 mars 2019

Flatten a multi dimensional array inside a multi dimensional array but retain keys?

$arr = [
    'name' => 'John',
    'access' => '1',
    'address' => [
        'line_1' => '10',
        'line_2' => 'example street',
    ],
]

How can I flatten this example array (or turn it into a collection) without losing keys, I've tried to use collect and flatten but this loses the keys.

I'm expecting this:

$arr = [
    'name' => 'John',
    'access' => '1',
    'line_1' => '10',
    'line_2' => 'example street',
 ]



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire