Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use sort() function in php ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 145
    Comment on it

    What is tht sort() function in php ?

    The sort() function sorts an indexed array in ascending order means lowest to highest .

    why use sort() function in php ?

    Sort() function basically use for sort the elements of the array in ascending alphabetical order:

    You can see below example of sort() function in php.

    1. <?php
    2.  
    3. $Name=array("Sanny","Mac","Brandam");
    4. //here $Name is a variable
    5. sort($Name);
    6. //now call the sort() for sorting name in alphabetical order
    7.  
    8. //loop start for count name
    9. for($i=0;$i<count($Name);$i++)
    10. {
    11. echo $Name[$i];
    12. echo "<br>";
    13. }
    14. ?>

    output will come following:

    Brandam

    Mac

    Sanny

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: