preg_replace_array

The preg_replace_array function replaces a given pattern in the string sequentially using an array:
<?php $string = 'The event will take place between :start and :end';

$replaced = preg_replace_array('/:[a-z_]+/', ['8:30', '9:00'], $string);
<?php         $escapedClassNamespace = preg_replace('/\\\/', '\\\\\\', $this->existingParser->classNamespace());



        return preg_replace_array(

            ["/namespace {$escapedClassNamespace}/", "/class {$this->existingParser->className()}/", "/{$this->existingParser->viewName()}/"],

            ["namespace {$this->classNamespace()}", "class {$this->className()}", $this->viewName()],

            $originalFile

        );

    }



    public function testContents($testType = 'phpunit')
<?php     {

        $this->assertSame(

            $expectedOutput,

            preg_replace_array($pattern, $replacements, $subject)

        );

    }

}