I got a problem. I need to show image - located in folder - if extencion is .png, .jpg, .jpeg or .gif . If extencion is not one of them then just show content of the file (.tex).
I made a script that works. But it shows just one of them (img or text file at once). I need show both of them at once.
<?php
$allFiles = scandir('post/');
$files = array_diff($allFiles, array('.', '..'));
foreach($files as $file)
{
$ext = substr(strrchr($file, '.'), 1);
if($ext = "jpg" || $ext = "png" || $ext = "jpeg" || $ext = "gif" ) {
echo "<div class=post>
<img width= 200px src=post/".$file.">
</div>";
}
else {
echo "<div class=post>
". file_get_contents("post/".$file) ."
</div>";
}
}
?>
Thanks a lot for help.