Results 1 to 3 of 3

Thread: PHP: reading files

  1. #1
    scoutt
    Guest
    without echoing the variable to the screen I don't think there is a hard and fast way to do it. maybe Dennis would know, but I don't think you can.

  2. #2
    denniswrenn
    Guest
    Here I come to the recue!
    file() reads a file into an array, each element is one line of the file.

    Code:
    <?php
    	$filearr = file("filename.txt");
    	$arrlen = count($filearr);
    	$matchvar = "hello";
    
    	for($i = 0; $i < $arrlen; $i++)
    	{
    		if($filearr[$i] == $matchvar)
    		{
    			$found = $filearr[$i];
    			$foundnum = $i;
    			break;
    		}
    	}
    ?>

  3. #3
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    SuperDennis the PHP warrior
    Alcohol & calculus don't mix.
    Never drink & derive.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width