note 22622 deleted from function.in-array by felipe
| From: | felipe@php.net | Date: | Sun, 30 Dec 2007 18:47:40 +0000 |
| Subject: | note 22622 deleted from function.in-array by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134462@lists.php.net to get a copy of this message | ||
Note Submitter: penneyda at hotmail dot com
----
If you are using in_array() to search through a file using the file() function, it seems you have to
add the line break "\n". It took me forever to figure out what the deal was.
Example:
$new_array = file("testing.txt");
if(in_array("$word_one : $word_two\n", $new_array))
{
print("success");
exit;
}
else
{
print("failure");
exit;
}
I just started learning PHP, but let me know if I have not figured this out correctly