sonoton345 Posted August 17, 2009 Share Posted August 17, 2009 I want to create a select form field with numbers 1 - 100 using $options = array('1'=>'1','2'=>'2',.........'100'=>'100'); e($form->select('fieldname',$options)); If I don't want to type all the numbers in, how can I create the array for $options? Quote Link to comment https://forums.phpfreaks.com/topic/170727-creating-an-array-for-a-select-form-field/ Share on other sites More sharing options...
irvieto Posted August 17, 2009 Share Posted August 17, 2009 Use a for sentence to fill the array... Quote Link to comment https://forums.phpfreaks.com/topic/170727-creating-an-array-for-a-select-form-field/#findComment-900432 Share on other sites More sharing options...
sonoton345 Posted August 17, 2009 Author Share Posted August 17, 2009 I thought so as well but when it comes to array I'm lost. Quote Link to comment https://forums.phpfreaks.com/topic/170727-creating-an-array-for-a-select-form-field/#findComment-900446 Share on other sites More sharing options...
jcombs_31 Posted August 17, 2009 Share Posted August 17, 2009 Something like this should work, assuming that you are in cakephp again. for($i = 0; $i <= 100; $i++) { $options["$i"] = $i; } echo $form->select('test', $options); Quote Link to comment https://forums.phpfreaks.com/topic/170727-creating-an-array-for-a-select-form-field/#findComment-900447 Share on other sites More sharing options...
sonoton345 Posted August 17, 2009 Author Share Posted August 17, 2009 You are star jcombs_31, thank you. I appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/170727-creating-an-array-for-a-select-form-field/#findComment-900455 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.