fork(1) download
  1. <?php
  2.  
  3. function jchwebdev_pullquote( $content ) {
  4. $pattern = "\[callout\](.*?)\[/callout\]";
  5. if(preg_match("@(?s)$pattern@", $content, $matches))
  6. {
  7. $content = preg_replace("@(?s)($pattern)((.*?</p>){3})@", '\2\3<blockquote class="pullquote">\2</blockquote>', $content);
  8. return $content;
  9. }
  10. return $content;
  11. }
  12.  
  13. $text = <<<EOT
  14. <p>If you wanna improve yer German, don't try to read Heine or some elevated crap... watch old episodes of [callout]Tatort or Bukow & Konig[/callout].</p>
  15. <p>If I were teaching a music appreciation I wouldn't teach Beethoven. I'd teach Stamitz and average composers.</p>
  16. <p>And here is a 3rd paragraph.</p>
  17. <p>And here is a 4th paragraph.</p>
  18. EOT;
  19.  
  20. echo jchwebdev_pullquote($text);
  21.  
Success #stdin #stdout 0.02s 24144KB
stdin
Standard input is empty
stdout
<p>If you wanna improve yer German, don't try to read Heine or some elevated crap... watch old episodes of Tatort or Bukow & Konig.</p>
<p>If I were teaching a music appreciation I wouldn't teach Beethoven. I'd teach Stamitz and average composers.</p>
<p>And here is a 3rd paragraph.</p><blockquote class="pullquote">Tatort or Bukow & Konig</blockquote>
<p>And here is a 4th paragraph.</p>