fork download
  1. <?php
  2.  
  3. $pattern = array("/\b(explanations)\b/i", "/\b(target)\b/i", "/\b(hints)\b/i", "/\b(hint)\b/i", );
  4. $replacement = array('$1 <i>(Erklärungen)</i>', '$1 <i>Ziel</i>', '$1 <i>Hinsweise</i>', '$1 <i>Hinweis</i>', );
  5. $string = "Target is to add some explanations (hints) from an array to this text. I am thankful for every hint.";
  6. echo preg_replace($pattern, $replacement, $string);
Success #stdin #stdout 0s 52488KB
stdin
Standard input is empty
stdout
Target <i>Ziel</i> is to add some explanations <i>(Erklärungen)</i> (hints <i>Hinsweise</i>) from an array to this text. I am thankful for every hint <i>Hinweis</i>.