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 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号