note 22622 added to function.in-array

From: Date: Tue, 25 Jun 2002 15:23:38 +0000
Subject: note 22622 added to function.in-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-32176@lists.php.net to get a copy of this message
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 -- http://www.php.net/manual/en/function.in-array.php http://master.php.net/manage/user-notes.php?action=edit+22622 http://master.php.net/manage/user-notes.php?action=delete+22622 http://master.php.net/manage/user-notes.php?action=reject+22622

« previous php.notes (#32176) next »