首页 > 解决方案 > 如何在 PHP 中将数字转换为单词?

问题描述

我在 PHP 中有 foreach 循环,它有诸如“one”之类的词,如下面的代码所示。我需要为每个 foreach 循环项写词。例如,“one”和第二项“two”等。

所以,我需要一个变量,它会为每个项目增加,它的值将作为单词写在 html 类中。

以最简单的方式,我该怎么做?

 <?php   if ( $settings['hekim_feature_list_department'] ) {
                                        foreach (  $settings['hekim_feature_list_department'] as $item ) { ?>

                                <div class="panel panel-default">
                                    <div class="panel-heading" role="tab" id="headingOne">
                                        <h4 class="panel-title">
                                            <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
                                                <i class="icon-Down-2 icon-1"></i>
                                                <i class="icon-Right-2 icon-2"></i>
                                                <?php echo $item['hekim_feature_list_title_department'];?>
                                            </a>
                                        </h4>
                                    </div>
                                    <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
                                        <div class="panel-body">
                                            <p><?php echo $item['hekim_team_member_description_department'];?></p>
                                        </div>

标签: php

解决方案


推荐阅读