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
How about to use string_replace() function ? Maybe something like : str_replace ($string , "Current Settings for Service Pack: 5.1.2600ServicePack3Build2600" , "Current Settings for Service Pack: 5.1.2600ServicePack3Build2600\nRecommended Settings for Service Pack"); PHP:
thanks for the suggestion..eventually i used preg_replace heh...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 PHP: