Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
基于php的搜索引擎图像库系统_Php_Html_Image - Fatal编程技术网

基于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>';
}
?>