Jump to content

Regular Expressions halp


andytan91

Recommended Posts

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

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]

Archived

This topic is now archived and is closed to further replies.

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