Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function lget($filename)
- {
- $handle = fopen($filename, 'r');
- while (FALSE !== $line = fgets($handle)) {
- yield $line;
- }
- fclose($handle);
- }
- $map = [
- ['file' => '1.txt', 'res' => 'Valid'],
- ['file' => '2.txt', 'res' => 'Invalid'],
- ['file' => '3.txt', 'res' => 'Fix'],
- ];
- $targetIP = '1.1.1.1';
- foreach ($map as $item) {
- $entries = lget($item["file"]);
- $found = FALSE;
- foreach ($entries as $entry) {
- if (strcmp(trim($entry), $targetIP) === 0) {
- echo $item["res"];
- $found = FALSE;
- break;
- }
- }
- if ($found) {
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement