3
두 개의 폴더 이미지와 사진이있는 큰 이미지가 있습니다.PHP를 통해 디렉토리의 파일에서 XML 생성
<images>
<image source="images/image1" lightbox="bigimages/image1" />
.....
</images>
나는 이런 식으로 뭔가가 :
<?php
// enter the path to the folder
$path = "images/";
// opendir
$dir_handle = @opendir($path) or die("Unable to open $path");
// table photos
$filetypes = array("jpg", "png");
// forming xml
$doc = new DomDocument('1.0');
$doc->formatOutput = true;
// forming images
$root = $doc->createElement('images');
$root = $doc->appendChild($root);
while ($file = readdir($dir_handle)) {
$file = rawurlencode($file);
$split = explode(".", $file);
$ext = strtolower($split[count($split)-1]);
if (in_array($ext, $filetypes)) {
// additional image
$item = $doc->createElement("image");
$item = $root->appendChild($item);
$file = $path.$file;
// adding an attribute source
$item->setAttribute('source', $file);
}
}
// closure
closedir($dir_handle);
// Save to XML
$doc->save("plik.xml");
echo "plik xml wygenerowany poprawnie!!!";
?>
을 그리고 지금 문제가 경로로 두 번째 속성을 추가하는 방법입니다
은이 같은 두 속성을 가진 XML 파일을 생성 할 "bigimages"디렉토리의 이미지.
는 일부 = "이미지 /에서는 image1.jpg"라이트 = "이미지 1 /"이미지 소스>이 처럼 생각 추가 나는 lightbox = "images1/image1.jpg을 가지고 싶다. 어떤 아이디어와 그것을 어떻게 알파벳순으로 처리합니까? – user1874062
ok problem solved :) – user1874062