Pushing array variable from inside array variable which has been created dynamically funtion

46 Views Asked by At

I would like to have this array from

array(
'label'=> 'Guest Capacity',
'desc'  => 'Total capacity of Guests',
'id'    => 'vessel_guest_capacity',
'type'  => 'select',
'options' => array ( 
    1 => array ( 'label' => '1', 'value' => 1 ),
    2 => array ( 'label' => '2', 'value' => 2 ),
    3 => array ( 'label' => '3', 'value' => 3 ),
    )
);

from this function, what is wrong with that?

array(
    'label'=> 'Guest Capacity',
    'desc'  => 'Total capacity of Guests',
    'id'    => 'vessel_guest_capacity',
    'type'  => 'select',
    'options' => function() { for($i = 1; $i <= 50; $i++){ if(!is_set($var)){ $var = array(); } $var[] = array ( 'label' => "$i", 'value' => $i ); } $this['options'] = $var; },
),

I tried with return but didn't have any luck.

0

There are 0 best solutions below