I didn't know the file function read the entire contents of the file to an array...
php code:
<?php
$one = "monkey";
// the HTML source of a URL.
$lines = file('./one_list.txt');
// Loop through our array, show HTML source as HTML source; and line numbers too.
foreach ($lines as $line_num => $line) {
if ($line == $one) {
echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n";
}
}
?>
Or better yet why are you putting your variables in ""
php code:
<?php
$one = "monkey";
$two = "baguette";
$one_array = file("one_list.txt");
$two_array = file("two_list.txt");
>>>if (in_array("$one",$one_array)){<<<
echo"one present!<br />";
>>> if(in_array("$two",$two_array)){<<<
echo"two present!";
}
else{
echo"two missing!";
}
}
else{
echo"one missing!";
}
?>
php code:
<?php
$one = "monkey";
$two = "baguette";
$one_array = file("one_list.txt");
$two_array = file("two_list.txt");
>>>if (in_array($one, $one_array)){<<<
echo"one present!<br />";
>>> if(in_array($two, $two_array)){<<<
echo"two present!";
}
else{
echo"two missing!";
}
}
else{
echo"one missing!";
}
?>
And if the above works you can simplify it:
php code:
<?php
if ( in_array("monkey", file("one_list.txt") ) ) { echo"one present!<br />";
if( in_array("baguette", file("two_list.txt") ) ){ echo"two present!"; }
else{ echo"two missing!"; }
} else { echo"one missing!"; }
?>