0

I have this array

Array
(
    [0] => Array
    (
    )

[1] => Array
    (
        [wpcf-fields-checkboxes-option-1a38bb558a59802a54ebd4b27c91431e-1] => Array
            (
                [0] => Attacco rapido
            )

        [wpcf-fields-checkboxes-option-0ad0b877a16a24fc4958374f171ef112-1] => Array
            (
                [0] => Bordo bianco
            )

    )

[2] => Array
    (
        [wpcf-fields-checkboxes-option-1a38bb558a59802a54ebd4b27c91431e-1] => Array
            (
                [0] => Attacco rapido
            )

        [wpcf-fields-checkboxes-option-3b2241533b2c56891d3fd57718409b85-1] => Array
            (
                [0] => Supporti regolabili
            )

    )

)

how i can get array with only values (Attacco rapido,Bordo bianco,Attacco rapido, Supporti regolabili)?

LF00
  • 27,015
  • 29
  • 156
  • 295
Leon
  • 141
  • 1
  • 3
  • 13

1 Answers1

5

using array_walk_recursive and passing $list by reference to fill it by the new values

array_walk_recursive($array, function ($value, $key) use (&$list) {
    $list[] = $value;
});

print_r($list);

Output :-

Array (
    [0] => Attacco rapido
    [1] => Bordo bianco
    [2] => Attacco rapido
    [3] => Supporti regolabili
)

live demo : https://3v4l.org/uhGlk

hassan
  • 7,812
  • 2
  • 25
  • 36