Heim  >  Fragen und Antworten  >  Hauptteil

Verwenden Sie PHP, um das Niveau zu berechnen

20170530161608_365.png

<?php
    $aaa = "67";
    $bbb = "98";
    $ccc = "43";
    ?>
<table class="auto-style1" style="width: 28%; height: 134px">
    <tr>
        <td class="auto-style2">姓名</td>
        <td class="auto-style2">成绩</td>
        <td class="auto-style2">等级</td>
    </tr>
    <tr>
        <td class="auto-style2">AAA</td>
        <td class="auto-style2"><?php
         echo $aaa;
 ?></td>
        <td class="auto-style2"></td>
    </tr>
    <tr>
        <td class="auto-style2">BBB</td>
        <td class="auto-style2"><?php
         echo $bbb;
 ?></td>
        <td class="auto-style2">&nbsp;</td>
    </tr>
    <tr>
        <td class="auto-style2">CCC</td>
        <td class="auto-style2"><?php
         echo $ccc;
 ?></td>
        <td class="auto-style2">&nbsp;</td>
    </tr>
</table>

Wie erreicht man eine hierarchische Zellenrangfolge?


wanfuwuwanfuwu2669 Tage vor720

Antworte allen(2)Ich werde antworten

  • PHP中文网

    PHP中文网2017-05-31 09:32:23

    <?php
    $list=array(
        array('name'=>'AAA','score'=>67,'dengji'=>0),
        array('name'=>'BBB','score'=>98,'dengji'=>0),
        array('name'=>'CCC','score'=>43,'dengji'=>0),
    );
    function cmp($a,$b){
        global $list;
        $a=$list[$a]['score'];
        $b=$list[$b]['score'];
        if($a>$b){
            return true;
        }
        return false;
    }
    uksort($list,'cmp');
    $list=array_values($list);
    echo '姓名|分数|名次<br>';
    foreach($list as $k=>$row){
        echo $row['name'].'|'.$row['score'].'|'.($k+1);
    }


    Antwort
    0
  • PHP中文网

    名次从高到低显示

    PHP中文网 · 2017-05-31 09:41:11
  • phpcn_u2725

    phpcn_u27252017-05-31 09:31:42

    成绩进行范围性的判断

    Antwort
    0
  • StornierenAntwort