我阅读了 php in_array手册并创建了一些代码行。
$handle = fopen("/path/to/file", "a") or die('Cannot open file:');
$y= $command_name1.$steps1;
$x=trim(shell_exec("grep -ri -o '$y' /path/to/file "));
$Z=array($x);
if (in_array($y,$z,false))
{
echo "thise 2 variables are already in this file";
fclose($handle);
}
else {
//write some thing on that file
}
但这给出了上述错误。我想知道的是,2个变量($command_name1
和$steps1
)可以加在一起并通过搜索in_array
吗?