我想列出2个目录中的文件但我收到了这些错误:
参数#1不是第62行的C:\ wamp \ www \ new.php中的数组:
$directory = '/openssl/bin/';
$extension = '.pem';
$directory2 = '/openssl/try/bin/';
$extension2 = '*.*';
if ( file_exists($directory) ) {
foreach(glob($directory.'*'.$extension) as $file){
foreach(glob($directory2.'*'.$extension2) as $file2){
$result = array_merge($file, $file2); // line 76 error 1
?>
<tr >
我希望输出成为2个目录中的文件名列表
<td> <?php echo basename($result); ?></td> // this should be list all the filename inside the 2 directory in table
file_get_contents():第76行 中的C:\ wamp \ www \ new.php中的文件名不能为空
$data = openssl_x509_parse(file_get_contents($result));
答案 0 :(得分:0)
嗨glob需要文件的物理路径。所以尝试运行此代码
$dir = __DIR__;
$directory = $dir.'/openssl/bin/';
$extension = '.pem';
$directory2 = $dir.'/openssl/try/bin/';
$extension2 = '*.*';
if ( file_exists($directory) ) {
$myArr = array_merge(glob($directory.'*'.$extension), glob($directory2.'*'.$extension2));
foreach($myArr as $file){
echo $file;
echo "<br>";
}
}
答案 1 :(得分:0)
<?php
$directory = '/openssl/bin/';
$extension = '.pem';
$directory2 = '/openssl/try/bin/';
$extension2 = '*.*';
if ( file_exists($directory) ) {
$myArr = array_merge(glob($directory.'*'.$extension), glob($directory2.'*'.$extension2));
foreach($myArr as $file){
echo $file;
echo "<br>";
}
}
?>
感谢帮助volkinc和其他人分享他们的意见和建议我得到了答案在这里我只是有点混淆全球执行代码感谢安排它为我volkinc 干杯!!