dragunu Posted December 28, 2006 Share Posted December 28, 2006 Greetings!I have the following code:[code]<?php$names = file("names.txt"); for($num=0;$num<count($names);$num++) { if ( "peter" == $names[$num] ) print "name is found!" ; }?>[/code]now, names.txt contains the following:rogerrobertpetersamin this order. However, the script is not prompting anything. As if Peter is not found in the list. Is there some other lines that are missing?Thanks a lot and seasons greetings, Link to comment https://forums.phpfreaks.com/topic/32107-solved-if-statement-not-working-in-file-array/ Share on other sites More sharing options...
sasa Posted December 28, 2006 Share Posted December 28, 2006 try [code] ...if ( "peter" == trim($names[$num]) ) ...[/code] Link to comment https://forums.phpfreaks.com/topic/32107-solved-if-statement-not-working-in-file-array/#findComment-148998 Share on other sites More sharing options...
dragunu Posted December 28, 2006 Author Share Posted December 28, 2006 yes it worked sasa.thanks a lot :) Link to comment https://forums.phpfreaks.com/topic/32107-solved-if-statement-not-working-in-file-array/#findComment-148999 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.