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, Quote 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] Quote 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 :) Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.