0

I have this code and it does what I want but even so it generates an error, when checking the error log it tells me that a variable is not assigned and I do not understand because in the line that indicates it I'm declaring it.

I include all the segment code to see if anyone can give me an idea of ​​what is happening


    <?php
            $archivos = scandir("../../filesusm/repository/noticias/");
            $num=0;
            for ($i=2; $i<count($archivos); $i++) 
                { 
                    $num++;
        ?>
        <div class="col-md-3">          
            <table class="table">
                <tr>
                    <td style="height: 150px !important;">
                        <?php

                        // the error code indicates this line
                            $extension = end(explode(".", $archivos[$i]));


                            if ( ($extension == "jpg") OR ($extension == "png") OR ($extension == "gif") OR ($extension == "jfif") OR ($extension == "webp")) {
                                $image = '<img src="../../filesusm/repository/noticias/'.$archivos[$i].'" class="img-thumbnail" style="height: 150px!important; width: 150px!important; border: 0px;" />';
                            }
                            elseif ( ($extension == "mp4") OR ($extension == "avi") OR ($extension == "ogv") OR ($extension == "webm")) {
                                $image = '<video controls style="height: 149px!important; width: 100%!important; border: 0px;" class="img-thumbnail"><source src="../../filesusm/repository/noticias/'.$archivos[$i].'" type="video/'.$extension.'">Tu navegador no implementa el elemento <code>video</code>.</video>';
                            }
                            elseif ( ($extension == "mp3") OR ($extension == "wav") OR ($extension == "ogg")) {
                                $image = '<div style="height: 150px!important; width: 100%!important;">
                                <audio controls style="width: 100%!important; border: 0px;"><source src="../../filesusm/repository/noticias/'.$archivos[$i].'" type="audio/'.$extension.'">Tu navegador no implementa el elemento <code>audio</code>.</audio></div>';
                            }
                            echo $image; 
                        ?>
                    </td>
                </tr>
                <tr>
                    <td style="height: 30px !important;">                       
                        <div id="foo" style="font-size:13px; overflow-wrap: break-word;word-break: break-word"><strong>(#: <?php echo $num;?>) Copiar para incluir en noticias:</strong><hr style="padding: 1px; margin: 1px; background: #006600" /> <em>../../filesusm/repository/noticias/<?php echo $archivos[$i]; ?></em><hr style="padding: 1px; margin: 1px; background: #006600" /></div>           
                        <a title="Descargar Archivo" href="../../filesusm/repository/noticias/<?php echo $archivos[$i]; ?>" download="<?php echo $archivos[$i]; ?>" style="color: #006600; font-size:16px;">Descargar: <span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span> </a> 
                        <a title="Eliminar Archivo" href="Eliminar.php?name=../../filesusm/repository/noticias/<?php echo $archivos[$i]; ?>" style="color: #ff0000; font-size:16px;" onclick="return confirm('Esta seguro de eliminar el archivo?');">Eliminar: <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> </a><br />
                    </td>
                </tr>
            </table>
        </div>
        <?php } ?>

0 Answers0