I'm building a simple chat box(no database, inputs are saved as txt file and images) for my website where users can share image and send text. Here's what I've came up so far:
$log = glob(__DIR__.'/chatlog/*');
foreach($log as $file){
if(pathinfo($file, PATHINFO_EXTENSION) === "jpg" || "jpeg" || "png"){
$name = basename($file);
echo "<div><img style='width: 150px;' src='chatlog/$name'alt='failed to load'</div>";
}
if(pathinfo($file, PATHINFO_EXTENSION) === "txt"){
$line = file($file);
echo $line[0];
}
}
The problem is that in the first if, the text file is being included so it returns a broken image.
How can I exclude text file in the first if?