sábado, 7 de febrero de 2015

ereg_replac

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

  • After the replacement has occurred, the modified string will be returned.
  • If no matches are found, the string will remain unchanged.

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

No hay comentarios:

Publicar un comentario