Jump to content

[SOLVED] If statement not working in File array.


dragunu

Recommended Posts

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:

roger
robert
peter
sam

in 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,

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.