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? 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... 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. 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); 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. 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
Archived
This topic is now archived and is closed to further replies.