fork(4) download
  1. <?php
  2.  
  3. $shortCodes = array("shortcode_name", "shortcode_name2", "shortcode_name3");
  4.  
  5. $text = <<< EOF
  6. My example text [shortcode_name]content of shortcode[/shortcode_name] is cool.
  7. another example text [shortcode_name2]content of shortcode[/shortcode_name2] is cool.
  8. Yet another example [shortcode_name3]content of shortcode[/shortcode_name3] is cool.
  9. EOF;
  10.  
  11.  
  12. foreach($shortCodes as $shortCode){
  13. $text = preg_replace("%\[$shortCode\].*?\[/$shortCode\]%i", '', $text);
  14. $text= preg_replace('/\s{2,}/i', ' ', $text); //remove 2 or more spaces
  15.  
  16. }
  17.  
  18. echo $text;
  19.  
  20.  
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
My example text is cool.
another example text is cool.
Yet another example is cool.