Wolf wrote:
All, I'm trying to figure out the logic piece, and I'm pretty sure I am missing something simple. 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. Wolf
based off your logic, I think I fixed your problem. don't forget about http://us3.php.net/break // Get a directory resource handler if ($handle = opendir('./bp_csv/')) { // Looping... while ( $file = readdir($handle) ) { // This checks to see if it is a file. Not a symlink, dir, socket, etc... // Your is_dir() test would have failed if it had come across a socket if ( is_file($file) ) { // Mind you that I have not used the escapeshell***() commands // that much. You might need to drop the escapeshellcmd(), since // you are creating the command inline, and you have already escaped // the input data with escapeshellarg() // Be sure to validate input $user = escapeshellarg(@$_POST[userid]); // Be sure to escape the command also $command = escapeshellcmd("grep \"{$user}\" ./bp_csv/{$file}"); // Run command and capture results $userinfo = exec($command); // Check to see if I got any results // Might want to do a little better result checking. // This would pass even if the command failes and hands back an error if ( ! empty($userinfo) ) { // ok, found the person, run the function userprofile($userinfo); // Exit while loop break; } } } } // Nothing was returned for any of the files that we found. if ( empty($userinfo) ) { echo "$user not found in any BP_CSV files, now running LDAP check<BR>"; ldap_check($user); } -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php