3v4l.org

run code in 300+ PHP versions simultaneously
<?php $prefix = 'pre_'; $clients = [ (object) ['user_login' => 'foo'], (object) ['user_login' => 'bar'], (object) ['user_login' => 'buzz'], ]; $result = [ 'label' => 'Assign to user', 'desc' => 'Choose a user', 'id' => $prefix . 'client', 'type' => 'radio', 'options' => array_map( fn($user) => [ 'label' => $user->user_login, 'value' => $user->user_login, ], $clients ) ]; var_export($result);
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
array ( 'label' => 'Assign to user', 'desc' => 'Choose a user', 'id' => 'pre_client', 'type' => 'radio', 'options' => array ( 0 => array ( 'label' => 'foo', 'value' => 'foo', ), 1 => array ( 'label' => 'bar', 'value' => 'bar', ), 2 => array ( 'label' => 'buzz', 'value' => 'buzz', ), ), )

preferences:
68.28 ms | 407 KiB | 5 Q