Jump to content

Fwrite a specific string under a specified string


andytan91

Recommended Posts

Hello guys i am trying to figure out how to fwrite a string for example "Recommended Settings for Service Pack" under "Current Settings for Service Pack: 5.1.2600ServicePack3Build2600". I figure i cant use line number as an argument because the file report may be dynamic so i will need to use Current Settings as an argument. Please guide me if you have any ideas..thanks:) !

 

auditreport 

table

ServicePackSetting

Service Pack Requirement: Fail

Current Settings for Service Pack: 5.1.2600ServicePack3Build2600 

MajorAuditandAccountPolicies 

Maximum Password Age Requirement: Fail

Current Settings for Maximum Password Age Requirement: 42 

Minimum Password Length: Fail

Current Settings for Minimum Password Length Requirement: 0

Eventually i used preg_replace...however i have met a problem here, the strings after Service Pack: are dynamic and thus i cant hardcode " 5.1.2600ServicePack2Build2600" in the replacement array..so how can i pass Example Current Settings stated below into the replacement array?

 

Example Current Settings

"Current Settings for Service Pack: 5.1.2600ServicePack2Build2600"

 

foreach($lines as $line)
{
$string1 = $line;
$patterns = array();
$patterns[0] = '/\bCurrent Settings for Service Pack:.*\b/';
$replacements = array();
$replacements[0] = "Current Settings for Service Pack: 5.1.2600ServicePack2Build2600
Recommended Settings for Service Pack: $servicepack";
$string1 = preg_replace($patterns , $replacements , $str

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.