Php 使用in_数组或strstr,但if语句似乎无法正常工作

Php 使用in_数组或strstr,但if语句似乎无法正常工作,php,if-statement,strstr,Php,If Statement,Strstr,以下是我对标题中提到的问题的代码: $folder = '/net/comp/home/data/'; $files1 = scandir($folder); $analysisno=($row['ANALYSIS_NUMBER']); //e.g.11wa666 //if ($test = strstr($folder,'$analysisno'))

以下是我对标题中提到的问题的代码:

                $folder = '/net/comp/home/data/';
                $files1 = scandir($folder);
                $analysisno=($row['ANALYSIS_NUMBER']); //e.g.11wa666
                //if ($test = strstr($folder,'$analysisno'))
                if (in_array($analysisno,$files1))              
                {       
                //echo " --$test completed, match found";
                echo "  <td BGCOLOR=\"#00ff00\">completed</td>\n";              
                }
                else
                {
                echo "  <td BGCOLOR=\"#00ffff\">pending</td>\n";
$folder='/net/comp/home/data/;
$files1=scandir($folder);
$analysisno=($row['ANALYSIS_NUMBER'])//e、 g.11wa666
//如果($test=strstr($folder,$analysisno'))
if(在数组中($analysisno,$files1))
{       
//echo“-$test已完成,找到匹配项”;
回显“已完成\n”;
}
其他的
{
回显“挂起\n”;
if语句似乎不能正常工作,就像测试时一样:上面的目录中有一个文件,其中包含一个if语句应该检查并输出完成的分析编号。(这就是问题所在)

(我只想检查指定目录中是否存在文件名中包含分析号的文件,然后输出“已完成”,如果文件夹中不存在分析号,则输出排队)

默认情况下,代码总是输出“挂起”,并且在必要时不输出“已完成”


谢谢您的帮助。

$files1=scandir($folder);
然后查看数组包含的内容

然后打印
$analysisno
值,并检查该值是否实际在数组中


你的代码看起来不错

你试过调试你的代码吗?打印变量的各种值吗?嗨,我已经这样做了,对不起,忘了提一下,例如analysisnumber中确实有值,例如11r3666和数据库中的所有其他值,它从数据库中获取它。var\u转储你的变量以查看类型,而且,它是否您有文件扩展名吗?@damien pirsy,谢谢您的回复,我正在检查文件名是否匹配,请您解释一下或者建议其他方法。@donok也许您应该将扩展名添加到分析编号中,例如11wa666