note 22622 deleted from function.in-array by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.