3v4l.org

run code in 500+ PHP versions simultaneously
<?php $records = [ [ "id" => 8, "username" => "macq", "owner" => [ [ "id" => 5, "name" => "Hyna Bora", "adress" => "ul.Baranio 17,34-567 Zadupie", "property" => [ [ "id" => 6, "name" => "Garaż", "adress" => "ul.Baranio 17,34-567 Zadupie", ] ], ], [ "id" => 6, "name" => "Kasia Doryghi", "adress" => "ul.Hellera 18,94-537 Katowice", "property" => [ [ "id" => 7, "name" => "Mieszkanie", "adress" => "ul.Hellera 18,94-537 Katowice", ] ] ] ] ] ]; foreach($records as $record){ foreach($record['owner'] as $recordowner){ if(array_key_exists("property", $recordowner)){ $Owner_names = array_column($recordowner['property'], 'name'); print_r($Owner_names); } } }
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.31, 8.3.0 - 8.3.31, 8.4.1 - 8.4.22, 8.5.0 - 8.5.7
Array ( [0] => Garaż ) Array ( [0] => Mieszkanie )

preferences:
90.51 ms | 1592 KiB | 4 Q