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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.