Count file in dir with matching $string at a line $var...

Discussion in 'Programming' started by Peuplarchie, Dec 9, 2008.

  1. #1
    Good day to you all,
    I'm wondering how can I count files in a directory that as a specific word in a specific line number which would be :

    
    // I know how to count folder...
      function CountDir($aDir, $aRecurse)
      {
        $Count = 0;
        $d = dir($aDir);
        while ($Entry = $d->Read())
        {
          if (!(($Entry == "..") || ($Entry == ".")))
          {
            if (Is_Dir($aDir . '/' . $Entry))
            {
              if ($aRecurse)
              {
                $Count += CountDir($aDir . '/' . $Entry, $aRecurse);
              }
            }
            else
            {
              $Count++;
            }
          }
        }
        return $Count;
      }
    
    
    // I would need to include something like this iguess..
    
    if ($lines[$line13] == "Pending"){
    count++
    }
    
    
    
    
    
    PHP:


    Thanks !
     
    Peuplarchie, Dec 9, 2008 IP
  2. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #2
    You can use egrep .
     
    it career, Dec 9, 2008 IP