RE: look at all files, then go elsewhere

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[snip]
I have a script that I want to check all files in a directory for
information, if it doesn't find it when all done, I want it to go
elsewhere, however if it does find it, I want it to break out of the
search and perform a function.

CODE:
if ($userinfo == "")
{
 if ($handle = opendir('./bp_csv/')) {
  while (false !== ($file = readdir($handle))) {
   if($file != '..' && $file != '.') {
    if(is_dir($file)) { //Diretory skipped
     } else {
     $command = 'cat ./bp_csv/' . $file . ' | grep '"';
     $user = $_POST[userid];
     $command .= $user . '"'';
     $userinfo=exec($command);
    // here's where it is multi-looping
     if ($userinfo =="")
     { 
       echo "$user not found in any BP_CSV files, now running LDAP
check<BR>";
       ldap_check($user);
     }
     else
     {
      // ok, found the person, run the function
      userprofile($userinfo);
     }
    }
   }
  }
 } 
}
else
{
 //original data has contents, go after user data
 userprofile($userinfo);
}
[/snip]

Put all of the locations you want to search in an array and loop through
the array.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux