使用in_array或STRSTR,但if语句似乎不能正确工作


using in_array or strstr but the if statement does not seem to work correctly

下面是我在标题中提到的问题的代码:

                $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";

if语句似乎不能正确工作,就像在测试时一样:上面的目录中有一个文件,其中包含一个分析编号,if语句应该检查并输出完成。(这就是问题所在)。

(我所要做的就是检查在其文件名中具有分析编号的文件是否存在于指定的目录中,然后输出'completed',如果文件夹中不存在分析编号,则输出队列)

默认情况下,代码总是输出'pending',必要时不输出completed。

谢谢你的帮助

$files1 = scandir($folder);之后打印$files1 array看看数组中包含了什么

之后打印$analysisno值并检查该值是否在数组中。

你的代码看起来不错