topical media & game development

talk show tell print

basic-regex-23-Eregi-ReplaceDemo.php / php



  <html>
  <head>
  <title>eregi_replace() Demo</title>
  </head>
  <body>
  <?php
  myPattern = "Doctor";
  myReplacement = "Dr.";
  myString = "Doctor Smith spoke with another doctor.";
  echo "<p>The original string was 'myString'.</p>";
  echo "<p>The pattern is 'myPattern'.</p>";
  echo "<p>The replacement text is 'myReplacement'.</p>";
  replacedString = eregi_replace(myPattern, myReplacement, myString);
  displayString = "<p>After replacment the string becomes: ' ";
  displayString = displayString . replacedString . "'.</p>";
  echo displayString;
  ?>
  </body>
  </html>


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.