3v4l.org

run code in 300+ PHP versions simultaneously
<?php $links = [ [ 'type_id' => '1', 'url' => '' ], [ 'type_id' => '2', 'url' => '' ] ]; $types = [ [ 'value' => 'facebook' ], [ 'value' => 'twitter' ] ]; $data = [ 'primary' => [ 'address_details' => [], 'contact_details' => [], 'social_links' => array_combine(array_column($types, 'value'), $links) ] ]; print_r($data);
Output for 7.1.25 - 7.1.33, 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.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
Array ( [primary] => Array ( [address_details] => Array ( ) [contact_details] => Array ( ) [social_links] => Array ( [facebook] => Array ( [type_id] => 1 [url] => ) [twitter] => Array ( [type_id] => 2 [url] => ) ) ) )

preferences:
82.42 ms | 409 KiB | 5 Q