Jump to content

[SOLVED] Looking for a command


liamthebof

Recommended Posts

Theres always a way.

 

<?php

   function findinfile($file, $search) {
       $file = file($file);
       for ($i = 0; $i < count($file); $i++) {
           if (strpos($file[$i], $search) !== false) {
               return ++$i;
           }
       }
       return false;
   }   

   if ($found = findinfile('foo.txt','foo')) {
       echo "foo was found on line number $found";
   } else {
       echo "foo was not found";
   }   

?>

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.