3v4l.org

run code in 500+ PHP versions simultaneously
<?php $records = [ [ 'id' => 2135, 'first_name' => 'John', 'last_name' => 'Doe', 'owner' => [ [ 'id' =>345, 'first_name' => 'Johnsssss', 'last_name' => 'Doe' ] ] ], [ 'id' => 3245, 'first_name' => 'Sally', 'last_name' => 'Smith', 'owner' => [ [ 'id' => 345, 'first_name' => 'Johnddddd', 'last_name' => 'Doe' ] ] ], [ 'id' => 5342, 'first_name' => 'Jane', 'last_name' => 'Jones', ], [ 'id' => 5623, 'first_name' => 'Peter', 'last_name' => 'Doe', ] ]; array_map(function($record){ if(array_key_exists("owner", $record)){ $first_names = array_column($record['owner'], 'id'); print_r($first_names); } }, $records); echo PHP_EOL; foreach($records as $record){ if(array_key_exists("owner", $record)){ $first_names = array_column($record['owner'], 'id'); print_r($first_names); } }
Output for rfc.property-hooks, git.master, git.master_jit
Array ( [0] => 345 ) Array ( [0] => 345 ) Array ( [0] => 345 ) Array ( [0] => 345 )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
48.24 ms | 1500 KiB | 3 Q