• $value
  • $value
  • $value
  • How can I fix the number counting from 0 to 100 in php

    119 Views Asked by At

    Suppose I have an array like that

    $test= array(5,4,8,9,3,7,2,10,1);
    

    Now I'll print them

    foreach($test as $key => $value){           
        echo "<ul><li>$value</li></ul>";
    }
    

    but I want my output will be all numbers showing serially like

    1
    2
    3
    4
    5
    7
    8
    9
    10
    

    then how ill filter them and how can I get that kind of output?

    1

    There are 1 best solutions below

    0
    user3425506 On

    This shows how to sort:

      <ul>
      <?php
        $test= array(5,4,8,9,3,7,2,10,1);
        sort($test);
        foreach($test as $key => $value){           
          echo "<li>$value</li>";
        }
      ?>
      </ul>