php - Warning: in_array() expects parameter 2 to be array -
i read php in_array manual , create code lines.
$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 in file"; fclose($handle); } else { //write thing on file } but gives above error. , want know is, can 2 variables($command_name1 , $steps1)adds , search through in_array ?.
$x isn't array, error.
take look in_array() definition , use.
as can see function signature
bool in_array ( mixed $needle , array $haystack [, bool $strict = false ] ) you need second argument (in case $haystack) array , not scalar value (whatever type is)
Comments
Post a Comment