RE: [PHP] look at all files, then go elsewhere

From: Date: Tue, 11 Sep 2007 15:23:05 +0000
Subject: RE: [PHP] look at all files, then go elsewhere
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-261942@lists.php.net to get a copy of this message
[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.

« previous php.general (#261942) next »