topical media & game development

talk show tell print

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



  <html>
  <head>
  <title>ereg_replace() Demo</title>
  </head>
  <body>
  <?php
  myPattern = "Hello";
  myReplacement = "Hi";
  myString = "Hello world!";
  echo "<p>The original string was 'myString'.</p>";
  echo "<p>The pattern is 'myPattern'.</p>";
  echo "<p>The replacement text is 'myReplacement'.</p>";
  replacedString = ereg_replace(myPattern, myReplacement, myString);
  displayString = "<p>After replacement 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.