Untitled

 avatar
unknown
plain_text
2 years ago
549 B
1
Indexable
<?php 
function sortuj($e1,$e2)
{
    if($e1%2==0){
        if($e2%2==0){
            return $e1 - $ e2;
        }
        else{
            return -1;
        }
    }
    else{
        if($e2%2==0){
            return 1;
        }
        else{
            return $e1 - $e2;
        }
    }
}

$tab1 = array(5,7,3,1,8,2,0,4,9,6);
echo "Przed sortowaniem <br>";
foreach($tab1 as $val){
    echo "$val";
}
echo "<br>";

usort($tab1, 'sortuj');
echo "po sortowaniu: <br>";
foreach($tab1 as $val){
    echo "$val";
}
?>
Editor is loading...