Copyright © tutorialspoint.com

PHP Function ereg_replace()

previous
Advertisements

Syntax

string ereg_replace (string pattern, string replacement, string originalstring);

Definition and Usage

The ereg_replace() function searches for string specified by pattern and replaces pattern with replacement if found. The ereg_replace() function operates under the same premises as ereg(), except that the functionality is extended to finding and replacing pattern instead of simply locating it.

Like ereg(), ereg_replace() is case sensitive.

Return Value

Example

Following is the piece of code, copy and paste this code into a file and verify the result.

<?php

$copy_date = "Copyright 1999";
$copy_date = ereg_replace("([0-9]+)", "2000", $copy_date);
print $copy_date;

?>

This will produce following result

Copyright 2000

previous

Copyright © tutorialspoint.com