3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php ob_start(); ?> flarg blarg dlarg <!-- BEGIN DYNAMIC BLOCK: guide_greeting --> filler content <!-- END DYNAMIC BLOCK: guide_greeting --> flarg blarg dlarg <?php $content = ob_get_clean(); function getDyanmicBlockContent($content, $tag) { $boundaries = (object) [ 'start' => sprintf('<!-- BEGIN DYNAMIC BLOCK: %s -->', $tag), 'end' => sprintf('<!-- END DYNAMIC BLOCK: %s -->', $tag), ]; $results = (object) [ 'start' => stripos($content, $boundaries->start), 'end' => stripos($content, $boundaries->end), ]; if ($results->start === false || $results->end === false || $results->start > $results->end) { return null; } $substr = substr($content, 0, $results->end); return $substr; } var_dump( getDyanmicBlockContent($content, 'guide_greeting') );
based on HTRhO
Output for 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.30 - 7.3.0beta1
string(78) "flarg blarg dlarg <!-- BEGIN DYNAMIC BLOCK: guide_greeting --> filler content "