file()

From: Date: Fri, 18 May 2001 23:27:53 +0000
Subject: file()
Groups: php.general 
Request: Send a blank email to php-general+get-53402@lists.php.net to get a copy of this message
hello, i have my file which reads like: dir3/dir3-3/ dir2/ dir1/ s now when i run this script: $a = file("exclude_dir.txt"); $t = "dir3/dir3-3/"; $temp = in_array($t, $a) ? "yes" : "no"; echo "\$a="; var_dump($a); echo "<br>"; echo "in_array(\$t=$t, \$a)=$temp"; i have this output: $a=array(4) { [0]=> string(13) "dir3/dir3-3/ " [1]=> string(6) "dir2/ " [2]=> string(6) "dir1/ " [3]=> string(1) "s" } in_array($t=dir3/dir3-3/, $a)=no as you noticed that in each element of the array "$a" a space is appended for an unknown reason! that's why my in_array() call returns "no" any ideas other than doing: $a = split(";", join('', file("myfile"))); or something? -elias

« previous php.general (#53402) next »