PHP Help
PHP Help
Out of context: Reply #4
- Started
- Last post
- 10 Responses
- rabbit0
if i understand correctly, you need two files:
fileWithFunction.php
<?phpfunction getAllImagesInDirectory($path) {
if ($handle = opendir($path)) {
$images = "[";
while (false !== ($file = readdir($handle))) {
if($file !== "." && $file !== "..") {
$images .= "{image : '$path$file', title : '', url : ''},";
}
}
closedir($handle);
return substr($images,0,strlen($images)-1) . "]";
}}
$output = getAllImagesInDirectory("C:\Users\jbstrand\Downloads");
?>
output.php:
<?php
require("fileWithFunction.php");
echo $output;
?>