Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.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-array_combine()_Php - Fatal编程技术网

PHP-array_combine()

PHP-array_combine(),php,Php,我一直在尝试使用php从我的服务器中制作一个基本的视频查看器,但由于我是php的新手,所以通常都失败了。我一直收到此错误-第**行的文件*中存在E_警告错误:array_combine()期望参数2为array,如果第**行的文件*中存在E_警告错误,则为null(同一行):为foreach()提供的参数无效 结果将不显示任何内容 我能做什么 顺便说一句,这是源代码 $dir = $_GET["path"]; $files = scandir($dir); $thelis

我一直在尝试使用php从我的服务器中制作一个基本的视频查看器,但由于我是php的新手,所以通常都失败了。我一直收到此错误-第**行的文件*中存在E_警告错误:array_combine()期望参数2为array,如果第**行的文件*中存在E_警告错误,则为null(同一行):为foreach()提供的参数无效

结果将不显示任何内容

我能做什么

顺便说一句,这是源代码

    $dir = $_GET["path"];
    $files = scandir($dir);
    $thelists=NULL;

    foreach (array_combine($files, $thelists) as $file => $thelist) {
            if ($file != "." || $file != ".." || pathinfo($file, PATHINFO_E$
                    $thelist .= '<a href=browse.php?path=.$_GET["path"].'.$$
            }
            else if ($file == "..") {
                    $thelist .= '<a href="javascript:history.back(1);">Back$
            }
            else {
                    echo "<a href=http://twentyone.ml/cloud/video.php?file=$
            }
    }
?>
<body>
<h1>Directory listing for <?php echo $dir; ?></h1>
<p><?php print_r($thelists); ?></p>
$dir=$\u GET[“path”];
$files=scandir($dir);
$thelists=NULL;
foreach(数组\u合并($files,$t列表)为$file=>$t列表){
如果($file!=“| |$file!=”。“| |路径信息($file,pathinfo)$

$thelist.='首先,我不明白为什么要在数组中组合
Null

$thelists
在数组组合中为空。您需要添加数组而不是空


$thelists=NULL;
更改为
$thelists=array();

通过以下代码删除了$thelists:

(一部分…只是一点foreach())

foreach($files as$file){
//$file\u info=new finfo\u open(FILEINFO\u MIME\u类型);
$mime_type=mime_content_type($dir.'/'.$file);//$file_info->buffer(file_get_contents($dir.'/'.$file));
如果($file!=“| |$file!=”。“| | strpos($mime_类型,'video')!==false){
回声“
”; }

是啊!

对不起,我已经试过了…不起作用,所以我尝试了null,甚至都不起作用。错误:array\u combine():两个参数的elementsTry数应该相等,array\u merge@icoret这类参数都起作用,但我没有得到文件列表…但感谢您的帮助:)@maninderpriet SinghHappy要帮助@iCore如果是帮助,那么接受它看看
foreach ($files as $file) {
        //$file_info = new finfo_open(FILEINFO_MIME_TYPE);
        $mime_type = mime_content_type($dir.'/'.$file);//$file_info->buffer(file_get_contents($dir.'/'.$file));
        if ($file != "." || $file != ".." || strpos($mime_type,'video') !== false) {
            echo '<a href=browse.php?path='.$_GET["path"].'/'.$file.'>'.$file.'</a><br />';
        }