Foreach loop inside array

That’s invalid syntax. You’d have to build the “parent” portions of the array first. THEN add in the sub-array stuff with the foreach loop:

$foo = array(
    'label' => 'Assign to user',
    'desc' => 'Choose a user',
    'id' => $prefix.'client',
    'type' => 'radio',
    'options' => array()
);

foreach ($clients as $user) {
    $foo['options'][] = array (  
        'label' => $user->user_login,  
        'value' => $user->user_login,
    );
}

Leave a Comment