fork download
  1. <?php
  2.  
  3. $inputs= array("===Heading 3===","====Heading 4====");
  4. foreach($inputs as $input) {
  5. echo preg_replace('/(?:\n|^)(={3,6})([^=]+)(\1)/e',"'<h'.strlen('$1').'>'.'$2'.'</h'.strlen('$1').'>'", $input)."\n";
  6. }
  7.  
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
<h3>Heading 3</h3>
<h4>Heading 4</h4>