Распечатка файлов PDF в директории с PHP 7.2

Функция ниже перечисляет все файлы PDF в выбранной директории. Также читает и распечатывает название песни внутри PDF (все они песни). Скрипт работает как шарм в PHP 5.6, но не в PHP 7.2. Я должен обновить до 7.2 из-за моей хостинговой компании.

function listPDF($dirtoread) {

if($handle = opendir("pdf/".$dirtoread)) {

//ny
$theFiles = array();

$count = 0;
while($currentfile = readdir($handle)) {

if(!ereg('^\.',$currentfile)) {
$theFiles[$count] = $currentfile;
$count++;
}
}

sort($theFiles,SORT_STRING);

for ($i=0; $i < count($theFiles); $i++){

$string = file_get_contents("pdf/".$dirtoread."/".$theFiles[$i]);
$start = strpos($string, "<dc:title>") + 10;
$length = strpos(substr($string, $start), '</dc:title>');

if ($length) {
$title = strip_tags(substr($string, $start, $length));
}


echo "<a  class='popup gallery pdf' rel='width:700;height:600'  href='pdf/".$dirtoread."/".$theFiles[$i]."' style='text-decoration:none; line-height:2em;'><img src='pdf/pdf_small.gif' align='bottom' border='0'> ".$title."</a><br>";


}
closedir($handle);
}
}

-1

Решение

Сожалею! Нашел это. Функция Ereg устарела в php 7 …

0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector