4
I’m wanting to grab a file extension but the name of some images comes type:
adsfasdfasd.234.asdfa.3rfr.jpg
asdfsdafasdfasdf.45eg.png
I’m trying to use the code:
<?php
if(is_dir("img/$noticia->idnoticia"))
{
$diretorio = "img/$noticia->idnoticia/";
if ($handle = opendir($diretorio)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
list($arquivo, $ext) = explode(strrchr($file,"."),$file);
if(($ext!="mp3")AND($ext!="wav")){
echo "<li><img src='$diretorio$arquivo.$ext'></li>";
But the result is being .
.
any hint?
I edited the question with the changes that suggested however now only returns = .
– Arsom Nolasco
@Arsomnolasco Is that you are not passing the name of a file instead of the directory in the variable
diretorio
? take a look at this commenting from the PHP website.– stderr
the problem is that I also need to list everything get the name of the separate file posted the complete code
– Arsom Nolasco
@Arsomnolasco I typed wrong the previous message.. initial problem still persists? have a look at the current answer code.
– stderr
yes yes it worked, somehow I found that using the LIST was mandatory, however it seems to me that the pathinfo function already lists, obr
– Arsom Nolasco