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 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. 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 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] Link to comment https://forums.phpfreaks.com/topic/208669-regular-expressions-halp/#findComment-1090141 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.