fork download
  1. <?php
  2.  
  3. $code = "<p>Test...test...test...</p> [gallery-1]";
  4.  
  5. preg_match_all("/\[gallery-(\d+)\]/", $code, $matches);
  6.  
  7. $galleries = array();
  8.  
  9. foreach ($matches[1] as $id) {
  10. $galleries[$id] = "<div class='gallery'><iframe src='http://m...content-available-to-author-only...s.fk/embed/" . $id . "/'></iframe></div>";
  11. }
  12.  
  13. foreach ($galleries as $id => $c) {
  14. $code = str_ireplace("[gallery-" . $id . "]", $c, $code);
  15. }
  16.  
  17. echo $code;
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
<p>Test...test...test...</p> <div class='gallery'><iframe src='http://m...content-available-to-author-only...s.fk/embed/1/'></iframe></div>