How to get the value of a column in a multidimensional array?

[
    "id" => 7
    "parent_id" => 9
    "child_id" => 11
    "children" => [
      0 =>  [
        "id" => 4,
        "parent_id" => 11,
        "child_id" => 2
      ]
      1 =>  [
        "id" => 5,
        "parent_id" => 11,
        "child_id" => 3
      ]
      2 =>  [
        "id" => 6,
        "parent_id" => 11,
        "child_id" => 4
      ]
    ]
  ]
  1 =>  [
    "id" => 8,
    "parent_id" => 10,
    "child_id" => 11
    "children" => [
      0 =>  [
        "id" => 4,
        "parent_id" => 11,
        "child_id" => 2
      ]
      1 =>  [
        "id" => 5,
        "parent_id" => 11,
        "child_id" => 3
      ]
      2 =>  [
        "id" => 6,
        "parent_id" => 11,
        "child_id" => 4
      ]
    ]
  ]

the generation rules are as follows
the child_id under parent_id- > child_id- > children of each object is an array
above the result is

[[9,11,2,3,4],[10,11,2,3,4]]
Php
Apr.05,2021

$arr = [
  [
    "id" => 7,
    "parent_id" => 9,
    "child_id" => 11,
    "children" => [
      [
        "id" => 4,
        "parent_id" => 11,
        "child_id" => 2
      ],
      [
        "id" => 5,
        "parent_id" => 11,
        "child_id" => 3]
      ,
      [
        "id" => 6,
        "parent_id" => 11,
        "child_id" => 4
      ]
    ]
  ],
  [
    "id" => 8,
    "parent_id" => 10,
    "child_id" => 11,
    "children" => [
      [
        "id" => 4,
        "parent_id" => 11,
        "child_id" => 2
      ], [
        "id" => 5,
        "parent_id" => 11,
        "child_id" => 3
      ], [
        "id" => 6,
        "parent_id" => 11,
        "child_id" => 4
      ]
    ]
  ]
];

$result = array_map(function ($item) {
  return array_merge([$item['parent_id'], $item['child_id']], array_map(function ($item) {
    return $item['child_id'];
  }, $item['children']));
}, $arr);

print_r($result);
Menu