PHP code example of zhalker / dumb-artifact-for-multi-level-contextual-parsing-in-php
1. Go to this page and download the library: Download zhalker/dumb-artifact-for-multi-level-contextual-parsing-in-php library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zhalker / dumb-artifact-for-multi-level-contextual-parsing-in-php example snippets
DumbContextualParser\ContextualReplaceText;
$text = "<html>\n<!-- ignore this comment -->\n<body>";
$rules = [
[
'scope_start' => '<body>',
'scope_end' => '</body>',
'self_replace' => [
'open' => '"',
'close' => '"',
'pattern' => '<em>%s</em>'
],
'inner_scopes' => []
]
];
$result = ContextualReplaceText::applyContexts($text, $rules);
echo $result;