Здравейте,
проблема ми е следния , трябва да накарам php да чете от директория и всяка нейна под директория за .xml файлове пробвах следното.
Малко помощ
проблема ми е следния , трябва да накарам php да чете от директория и всяка нейна под директория за .xml файлове пробвах следното.
Код:
function readDirs($path) {
$dirHandle = opendir($path);
while ($item = readdir($dirHandle)) {
$newPath = $path . DIRE . $item;
if (is_dir($newPath) && $item != '.' && $item != '..') {
//$newPaths = $newPath . "/";
return $newPath;
readDirs($newPath);
}
}
// return readDir();
}
function read_files($allf) {
return readDirs("books");
$allf = readDirs();
echo "<table style='width:100%' border=1> <tr>"
. "<th> Author </th> <th> Book </th> <th> Date Updated </th></tr>";
foreach (glob("{$allf}*.xml") as $filename) {
$xml_file = file_get_contents($filename, FILE_TEXT);
$xml = simplexml_load_string($xml_file);
$bookname = (string) $xml->name;
$bookauthor = (string) $xml->author;
$bookdate = date("F d Y H:i:s.", filemtime($filename));
echo ' <tr><th> ' . $bookauthor . " </th>";
echo '<th>' . $bookname . '</th>';
echo '<th>' . $bookdate . '</th> </tr>';
}
}