Home >> PHP >> preg_replace() function in PHP

preg_replace() function in PHP

The preg_replace() function used for a regular expression search and replace.

Syntax

mixed preg_replace (mixed pattern, mixed replacement, mixed string [, int limit [, int &$count]] );

Example

$var="Year 2017";

$copyvar=preg_replace("[0-9]","2000",$var);

echo $copyvar;

Output

Year 2000

Post Your Comment

Next Questions
File handling
fopen() function
fclose() function
fread() function
create the file
Check the file is available or not
Destroy the file
Write into the file
Create into folder
Remove a folder
touch() function
file_exits() function
unlink() function
fwrite() function
mkdir() function
rmdir() function
is_dir() function
file_get_contents() function
fgets() function
basename() function
chgrp() function
chmod() function
chown() function
clearstatcache() function
copy() function

Copyright ©2022 coderraj.com. All Rights Reserved.