3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $d = [ [ 'id' => 1, 'name' => 'bir', 'children' => [ [ 'id' => 1001, 'children' => [ [ 'id' => 10011, 'parent_id' => 1001, 'name' => 'onbinonbir', ], [ 'id' => 10012, 'parent_id' => 1001, 'name' => 'onbinoniki', ] ] ], [ 'id' => 1002, 'children' => [ [ 'id' => 10021, 'parent_id' => 1002, 'name' => 'onbinyirmibir', ], [ 'id' => 10022, 'parent_id' => 1002, 'name' => 'onbinyirmiiki', ] ] ] ] ], [ 'id' => 2, 'name' => 'iki', 'children' => [ [ 'id' => 2001, 'children' => [ [ 'id' => 20011, 'parent_id' => 2001, 'name' => 'yirmibinonbir', ], [ 'id' => 20012, 'parent_id' => 2001, 'name' => 'yirmibinoniki', ] ] ], [ 'id' => 2002, 'children' => [ [ 'id' => 20021, 'parent_id' => 2002, 'name' => 'yirmibinyirmibir', ], [ 'id' => 20022, 'parent_id' => 2002, 'name' => 'yirmibinyirmiiki', ] ] ] ] ] ]; $birinciler = array_column($d, 'id', 'id'); //var_dump($birinciler); $ikinciler = array_column($d, 'children', 'id'); var_dump($ikinciler); $ucunculer = array_column($ikinciler, 'children'); //var_dump($ikinciler);
Output for 7.1.0
array(2) { [1]=> array(2) { [0]=> array(2) { ["id"]=> int(1001) ["children"]=> array(2) { [0]=> array(3) { ["id"]=> int(10011) ["parent_id"]=> int(1001) ["name"]=> string(10) "onbinonbir" } [1]=> array(3) { ["id"]=> int(10012) ["parent_id"]=> int(1001) ["name"]=> string(10) "onbinoniki" } } } [1]=> array(2) { ["id"]=> int(1002) ["children"]=> array(2) { [0]=> array(3) { ["id"]=> int(10021) ["parent_id"]=> int(1002) ["name"]=> string(13) "onbinyirmibir" } [1]=> array(3) { ["id"]=> int(10022) ["parent_id"]=> int(1002) ["name"]=> string(13) "onbinyirmiiki" } } } } [2]=> array(2) { [0]=> array(2) { ["id"]=> int(2001) ["children"]=> array(2) { [0]=> array(3) { ["id"]=> int(20011) ["parent_id"]=> int(2001) ["name"]=> string(13) "yirmibinonbir" } [1]=> array(3) { ["id"]=> int(20012) ["parent_id"]=> int(2001) ["name"]=> string(13) "yirmibinoniki" } } } [1]=> array(2) { ["id"]=> int(2002) ["children"]=> array(2) { [0]=> array(3) { ["id"]=> int(20021) ["parent_id"]=> int(2002) ["name"]=> string(16) "yirmibinyirmibir" } [1]=> array(3) { ["id"]=> int(20022) ["parent_id"]=> int(2002) ["name"]=> string(16) "yirmibinyirmiiki" } } } } }