基于php的搜索引擎图像库系统
我正在尝试用关键字制作一个图像库系统。 每个图像都有一个基于php的搜索引擎图像库系统,php,html,image,Php,Html,Image,我正在尝试用关键字制作一个图像库系统。 每个图像都有一个.php文件,其中包含一些变量: $keywords = 'Keywords that describe the image'; $src = 'directory path leading to the image'; $other = 'any specific remarks about the image'; 每个图像的文件都存储在名为imageinfo的目录中。 如何将目录imageinfo中文件中列出
.php
文件,其中包含一些变量:
$keywords = 'Keywords that describe the image';
$src = 'directory path leading to the image';
$other = 'any specific remarks about the image';
每个图像的文件都存储在名为imageinfo
的目录中。
如何将目录imageinfo
中文件中列出的所有图像显示在一个.php
文件中?它们都有相同的变量名。我可以做一个搜索引擎系统来搜索文件吗?
这很难解释,如果你不明白,我理解-请随便拿一杯健怡可乐过来,把你的问题写在评论里 试试这个:(您必须填写正确的imageinfo文件夹)
用于获取目录内容的签出。一般来说,把你的问题分解成小块,寻找解决每一小块问题的方法,如果你真的尝试过一些东西,并且真的被卡住了,就只在这里发布一个问题。与其发明一些不那么好也不那么快的东西,不如使用数据库?类似于MySQL
的东西非常易于使用,可以满足您的所有需求。我建议你自己去买一杯健怡可乐,安装MySQL
,如果你有任何问题,请回到这里。
<?php
// Folder with all the Info PHP files
$infodir = __DIR__ .'/imageinfo/';
// read Folder contens
$files = scandir( $infodir );
// Array to store all image infos
$allimages = array();
// loop, file for file
foreach ($files as $file) {
// . and .. are in the array of files, but we don't need them
if( $file != '..' && $file != '.' ){
//path to actual Image Info file
$thisfile = $infodir.'/'.$file;
//Check if file exists
if( is_file( $thisfile ) ){
//parse file
include( $thisfile );
//add vars to Array
$allimages[] = array(
'keywords' => $keywords,
'src' => $src,
'other '=> $other
);
}
}
}
//Output Data of all files
echo '<pre>';
print_r( $allimages );
echo '<pre>';
//show images in browser
foreach ($allimages as $image ) {
echo '<div class="img">';
echo '<img src="'.$image['src'].'" title="" alt="" >';
echo '<br />';
echo $image['keywords'];
echo '<br />';
echo $image['other'];
echo '</div>';
}
?>