andytan91 Posted July 23, 2010 Share Posted July 23, 2010 Hello guys basically i am doing an edit policy function which uses the power of regular expression(preg_replace). But i have a problem here. The below is the text output from the DOS command whereby i will need to edit the START_TYPE of the following services. My question is how to make preg_replace to differentiate the START_TYPE that belongs to each service?? START_TYPE:DISABLED DISPLAY_NAME:Alerter START_TYPE:AUTO_START DISPLAY_NAME:AutomaticUpdates START_TYPE:DEMAND_START DISPLAY_NAME:BackgroundIntelligentTransferService START_TYPE:DISABLED DISPLAY_NAME:ClipBook Quote Link to comment https://forums.phpfreaks.com/topic/208669-regular-expressions-halp/ Share on other sites More sharing options...
gwolgamott Posted July 23, 2010 Share Posted July 23, 2010 http://www.phpfreaks.com/forums/index.php/board,43.0.html Probably get more responses in that forum. Quote Link to comment https://forums.phpfreaks.com/topic/208669-regular-expressions-halp/#findComment-1090136 Share on other sites More sharing options...
andytan91 Posted July 23, 2010 Author Share Posted July 23, 2010 alright i'll post there thx Quote Link to comment https://forums.phpfreaks.com/topic/208669-regular-expressions-halp/#findComment-1090138 Share on other sites More sharing options...
.josh Posted July 23, 2010 Share Posted July 23, 2010 regex not necessary $file = file('test.txt'); $c = 0; foreach ($file as $row) { $row = explode(':',trim($row)); $list[floor($c)][$row[0]] = $row[1]; $c += .5; } echo "<pre>"; print_r($list); [pre] Array ( [0] => Array ( [sTART_TYPE] => DISABLED [DISPLAY_NAME] => Alerter ) [1] => Array ( [sTART_TYPE] => AUTO_START [DISPLAY_NAME] => AutomaticUpdates ) [2] => Array ( [sTART_TYPE] => DEMAND_START [DISPLAY_NAME] => BackgroundIntelligentTransferService ) [3] => Array ( [sTART_TYPE] => DISABLED [DISPLAY_NAME] => ClipBook ) ) [/pre] Quote Link to comment https://forums.phpfreaks.com/topic/208669-regular-expressions-halp/#findComment-1090141 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.