I have a code where I want to show the files that are inserted.
The names are contained in a array
that I fetch from the database. They are presented the way I want but is there any way to sort? As for example to appear the images first and then the others without extensions? So I have my code.
<?php
$count=explode(",", $mos['files']);
foreach($count as $i){
$ext=substr($i, strpos($i, ".") + 1);
if($ext=="png" || $ext=="PNG" || $ext=="jpg" || $ext=="JPEG" || $ext=="JPG" || $ext=="jpeg"){
echo '<img src="../images/documentos/'.$i.'" />';
}else{
echo '<li>'.$i.'</li>';
}
}
?>
I give as an example the following array
: ajax.png,array.pdf,algo.jpg,tres.docx,sentido.doc