note 74161 rejected from function.in-array by bobby

From: Date: Wed, 28 Mar 2007 04:22:44 +0000
Subject: note 74161 rejected from function.in-array by bobby
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-124867@lists.php.net to get a copy of this message
Note Submitter: hirens85 at gmail dot com ---- I am trying to write a script that takes a text file with entries aa bb cc dd ee ff gg exactly as typed above, each entry seperated by the enter key, and put them into an array. I want to be able to search through this array and check if bb exists in the array and if it does I want the program to print something of my choice. I have been trying this for some time with no luck. Here is my code that doesn't work. <?php $filename = "file.txt"; $contents = file($filename); if (in_array("bb", $contents)) { echo "bb 1"; else echo "bb 0"; } ?>

« previous php.notes (#124867) next »