How to show the values and differences of arsort (); krsort (); ksort (); sort (); and etc in echos? [closed]

-1

Exercise proposed by the teacher.

C-) Create a function in PHP that feeds an array with notes from your sophomore year of college. Use the following array sorting commands and tell what each of these commands does. sort (), asort (), ksort (), arsort (), krsort (). Plot the screenshot and result code in .doc.

    
asked by anonymous 09.04.2017 / 05:08

1 answer

2

Use for , like this:

<?php

$notas = array( 5, 1, 2, 0, 2, 3 );

sort($notas);

for ($i = 0; $i < count($notas); $i++) {
    echo $notas[$i], PHP_EOL;
}

If it is displayed on an html page, change PHP_EOL (line break) to <br> :

for ($i = 0; $i < count($notas); $i++) {
    echo $notas[$i], '<br>';
}

The rest you find in the documentation:

09.04.2017 / 05:26