dongxiongshi9952 2014-11-18 20:22
浏览 43
已采纳

如何打印定义的常量数组?

I think that I have an easy questions, but I'm unable to find what I'm looking wrong!!

I've an array where there are some strings:

$tipus_membre = array("lider","colider","vetera","membre");

and this strings are defined:

define("LIDER","Leader");
define("COLIDER","Co-leader");
define("VETERA","Elder");
define("MEMBRE","Member");

I'm trying to print in a form but i'm unable to get it. With this first option i get only the name "lider", "colider"....:

<select name="cla_tipus" required>
<?php
for($i=0;$i<count($tipus_clan);$i++){
    echo '<option value="'.$i.'">'.$tipus_membre[$i].'</option>';
}
?>
 </select> 

and if i put:
constant($tipus_clan[$i]);

I get nothing.

(Edited the $var)

  • 写回答

4条回答 默认 最新

  • dsiimyoc804955 2014-11-18 20:40
    关注

    Thanks to all for the quick answers, finally the problem was where you said, in the case-sensitive.

    The code now it works with a minor change and it's:

    <?php
    for($i=0;$i<count($tipus_clan);$i++){
        echo '<option value="'.$i.'">'.constant(strtoupper($tipus_membre[$i])).'</option>';
    }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部