diff options
Diffstat (limited to 'inc/io.php')
-rw-r--r-- | inc/io.php | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/inc/io.php b/inc/io.php index 1939dc6a0..e1c4d1eb9 100644 --- a/inc/io.php +++ b/inc/io.php @@ -92,10 +92,12 @@ function io_saveFile($file,$content,$append=false){ * * Uses gzip if extension is .gz * + * 2005-10-14 : added regex option -- Christopher Smith <chris@jalakai.co.uk> + * * @author Steven Danz <steven-danz@kc.rr.com> * @return bool true on success */ -function io_deleteFromFile($file,$badline){ +function io_deleteFromFile($file,$badline,$regex=false){ if (!@file_exists($file)) return true; io_lock($file); @@ -108,10 +110,14 @@ function io_deleteFromFile($file,$badline){ } // remove all matching lines - $pos = array_search($badline,$lines); //return null or false if not found - while(is_int($pos)){ - unset($lines[$pos]); - $pos = array_search($badline,$lines); + if ($regex) { + $lines = preg_grep($badline,$lines,PREG_GREP_INVERT); + } else { + $pos = array_search($badline,$lines); //return null or false if not found + while(is_int($pos)){ + unset($lines[$pos]); + $pos = array_search($badline,$lines); + } } if(count($lines)){ |