Dear Friends i download sours file from my server , i see there are lots of unnecessary space between lines, how can i remove it, if i do that manually it will take lots of time so if you have any idea tell me. example I want to do it like
Just change the $base and it will scan all directories inside the $base directory removing all BLANK lines from all files ending with the extension .php! <? $base = array ( 'f:/www/docs/files/' ); // change = f:/www/docs/files/ while ( ! empty ( $base ) ) { $next = array_pop ( $base ); foreach ( glob ( $next . '*.php' ) AS $item ) { if ( ! is_dir ( $item ) ) { file_put_contents ( $item, preg_replace ( array ( "#^\s*\r?\n+#s", "#\s*\r?\n+$#s", "#\s*\r?\n+#s" ), array ( "", "", "\r\n" ), file_get_contents ( $item ) ) ); } else { $base[] = $item . '/'; } } } echo 'done, removing extra lines'; ?> PHP:
Easier: Open the file Click CTRL + F Select "Current document" in "Find in" (You can also select the folder if you have multiple files) Search in "Source code" Tick "Use regular expression" Type "[\r\n]{2,}" (without quotes) in "Find" Type "\n" (without quotes) in "Replace" Press "Replace All" Done.