I don't know how to solve the problem about Notice
correctly defining the variable $archi
so that I can correctly list the contents of the directory.
I sincerely appreciate any kind of help or explanation, this is the code:
<?php
// Lista los temas alfabeticamente
$ruta = "archivos/songs/";
$filehandle = opendir($ruta);
while (false !== ($file = readdir($filehandle))) {
if ($file != "." && $file != ".." && substr($file,-4)==".mp3") {
$arch=$file;
$archi=$arch.'*'.$archi;
}
}
closedir($filehandle);
// Inicio paginación
$archivosfile = explode ("*", $archi);
sort($archivosfile);
$currentpage = $_SERVER['PHP_SELF']; // Página donde se encuentra
$total=(count($archivosfile)-1);
$maxRows = 10; // Cantidad máxima de archivos a mostrar por página
$pageNum = 0;
if (isset($_GET['pag'])) {
$pageNum = intval($_GET['pag']);
}
$startRow = $pageNum * $maxRows;
if (isset($_GET['pag'])) {
$pageNum = intval($_GET['pag']);
}
$startRow = $pageNum * $maxRows;
$totalRows = $total;
$totalPages = ceil($totalRows/$maxRows)-1;
$archivos = array_slice($archivosfile, $startRow, $maxRows);
?>
You are creating the variable
$archi
in one scope and trying to access it from a different one, to have it available outside the if and the loop you have to create it outside, for this: