[insert_php]
function cmp($a, $b)
{
return strcmp($a->getFilename(), $b->getFilename());
}
$allFilesInfo = null;
$filesx = new DirectoryIterator(«wp-content/uploads/2017/competencias/matutina»);
foreach ($filesx as $fileInfo) {
/* we need to clone a fileInfo object into array, not just assign it */
$allFilesInfo[] = clone $fileInfo;
}
/* Alphabetically sorting the array with DirectoryIterator objects, by filename */
usort($allFilesInfo, ‘cmp’);
foreach ($allFilesInfo as $file) {
if ($file->isFile()) {
$path = $file->getPath();
$name = rawurlencode($file->getFilename());
$namex = utf8_decode($file->getPathname());
$url = «https://wordpress.instcamp.edu.mx/».$namex;
$path = utf8_encode($path);
// $url = rawurlencode(«https://wordpress.instcamp.edu.mx/».$path.»/».$name);
$url = «https://wordpress.instcamp.edu.mx/».$path.»/».$name;
//echo $url.»
«;
$name = utf8_encode($file->getFilename());
//echo «$name
«;
echo «$name
«;
}
}
[/insert_php]