andytan91 Posted August 16, 2010 Share Posted August 16, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/210836-fwrite-a-specific-string-under-a-specified-string/ Share on other sites More sharing options...
andytan91 Posted August 16, 2010 Author Share Posted August 16, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/210836-fwrite-a-specific-string-under-a-specified-string/#findComment-1099935 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.