dongxiongshi9952 2014-11-19 04: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-19 04: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条)

报告相同问题?

悬赏问题

  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题