作者kylekai (这年头,闪光都不闪了..)
看板PHP
标题Re: [心得] 输出<select>下拉选单的小撇步
时间Mon Jun 23 15:29:08 2008
※ 引述《lgzenith (封影)》之铭言:
: 照个人喜好修改一下
: function make_select($array,$default_key=null,$attributes=null){
: $htm = "<select $attribuges >";
: $str = '<option value="%s"%s>%s</option>';
: foreach($array as $key=>$text){
: $sel = '';
: if ($key == $default_key){
: $sel = ' selected="selected"';
: }else{
: $sel = '';
: }
: printf($str, $key, $sel, $text );
: }
: $htm .= '</select>';
: return $htm;
: }
: 後来比较喜欢用这种方式,我个人认为比较容易读,因为以前"$xxx".'xxx'这种写法
: 我看起来实在是很不舒服。
: 还有就是尽量照网页标准写法来
: 到现在都还没有吃午餐,为什麽我还在写程式= =
如果有用 Smarty 的话...
也可以参考这个..
http://www.smarty.net/manual/en/language.function.html.options.php
若是你用的是 date, date time 的话...
http://www.smarty.net/manual/en/language.function.html.select.date.php
http://www.smarty.net/manual/en/language.function.html.select.time.php
--
我是上来领便当的...
逛 php 版, database 版只是顺便而已...
http://blog.darkhero.net 个人网志
http://phorum.study-area.org/index.php/board,31.0.html
公司缺人 PHP 网站程式设计师(中初阶学徒可), 熟 MVC 尤嘉~ 请发站内信给我...
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.130.210.124