Hello guys i am wondering what ways are there to split the contents of a file using php. Below is the example, i would like is there any way to separate the contents into three different files using @echo off as an argument to split the file..thanks in advance! @echo off rem systeminfo | findstr OS | findstr -v BIOS >> hi.txt rem findstr /C:"OS Version: 5.1.2600 Service Pack 2 Build 2600" final.doc rem cd C:\UnxUtils\usr\local\wbin rem systeminfo | grep -w "\(OS Name\|OS Version\)" >> final.doc systeminfo | findstr /C:"OS Version" | findstr -v BIOS >> C:\final.doc systeminfo | findstr /i /C:"Service Pack 4" if %errorlevel%==0 ( echo Service_Pack_Requirement:Pass >> C:\final.doc ) else ( echo Service_Pack_Requirement:Fail >> C:\final.doc ) @echo off rem net accounts | findstr password | findstr -v maintained | findstr -v Minimum.password.age >> final.doc net accounts > hi.txt setlocal EnableDelayedExpansion for /f "delims=" %%a in (hi.txt) do ( set line=%%a set line=!line: =! echo !line! >> final.doc ) net accounts | findstr /C:"Maximum password age (days)" >> c:\final.doc findstr /C:"Maximumpasswordage(days):50" final.doc if %errorlevel%==0 ( echo Maximum_Password_Age_Requirement:Pass >> C:\final.doc ) else ( echo Maximum_Password_Age_Requirement:Fail >> C:\final.doc ) net accounts | findstr /C:"Minimum password length" >> c:\final.doc findstr /R /C:"Minimumpasswordlength:50" final.doc if %errorlevel%==0 ( echo Minimum_Password_Length:Pass >> C:\final.doc ) else ( echo Minimum_Password_Length:Fail >> C:\final.doc ) del hi.txt del final.doc @echo off rem secedit /export /cfg u.txt /areas SECURITYPOLICY cd C:\ DumpSec.exe /rpt=policy /saveas=fixed /outfile=policies.txt findstr /i /C:"Privileged Account Logon: No auditing" policies.txt if %errorlevel%==0 ( PHP:
Try this: <?php $filename = 'Text_file_to_be_split.txt'; $delimiter = '@echo off'; $lines = file($filename); $index = 0; foreach ($lines as $line) { if (strpos($line, $delimiter) === 0) { $index++; continue; } $n = explode('.', $filename); $fp = fopen($n[0] . '.' . $index . '.' . $n[1], 'a+'); fwrite($fp, $line); fclose($fp); } ?> PHP: