fork(1) download
  1. <?php
  2.  
  3. function jchwebdev_pullquote( $content ) {
  4. $pattern = "~\[callout\](.*?)\[/callout\]~s";
  5. if(preg_match($pattern, $content, $matches))
  6. {
  7. $content = preg_replace($pattern, '$1', $content);
  8. $pullquote = '<blockquote class="pullquote">' .$matches[1] . '</blockquote>';
  9. $content = preg_replace("@(.*?</p>){3}\K@s", $pullquote, $content);
  10. return $content;
  11. }
  12. return $content;
  13. }
  14.  
  15. $text = <<<EOT
  16. <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>
  17. <p>If I were teaching a music appreciation I wouldn't teach Beethoven. I'd teach Stamitz and average composers.</p>
  18. <p>And here is a 3rd paragraph.</p>
  19. <p>And here is a 4th paragraph.</p>
  20. EOT;
  21.  
  22. echo jchwebdev_pullquote($text);
  23.  
Success #stdin #stdout 0.02s 24192KB
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>